annotate DEPENDENCIES/generic/include/boost/proto/literal.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 ///////////////////////////////////////////////////////////////////////////////
Chris@16 2 /// \file literal.hpp
Chris@16 3 /// The literal\<\> terminal wrapper, and the proto::lit() function for
Chris@16 4 /// creating literal\<\> wrappers.
Chris@16 5 //
Chris@16 6 // Copyright 2008 Eric Niebler. Distributed under the Boost
Chris@16 7 // Software License, Version 1.0. (See accompanying file
Chris@16 8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9
Chris@16 10 #ifndef BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
Chris@16 11 #define BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
Chris@16 12
Chris@16 13 #include <boost/config.hpp>
Chris@16 14 #include <boost/proto/proto_fwd.hpp>
Chris@16 15 #include <boost/proto/expr.hpp>
Chris@16 16 #include <boost/proto/traits.hpp>
Chris@16 17 #include <boost/proto/extends.hpp>
Chris@16 18
Chris@16 19 namespace boost { namespace proto
Chris@16 20 {
Chris@16 21 namespace utility
Chris@16 22 {
Chris@16 23 /// \brief A simple wrapper for a terminal, provided for
Chris@16 24 /// ease of use.
Chris@16 25 ///
Chris@16 26 /// A simple wrapper for a terminal, provided for
Chris@16 27 /// ease of use. In all cases, <tt>literal\<X\> l(x);</tt>
Chris@16 28 /// is equivalent to <tt>terminal\<X\>::type l = {x};</tt>.
Chris@16 29 ///
Chris@16 30 /// The \c Domain template parameter defaults to
Chris@16 31 /// \c proto::default_domain.
Chris@16 32 template<
Chris@16 33 typename T
Chris@16 34 , typename Domain // = default_domain
Chris@16 35 >
Chris@16 36 struct literal
Chris@16 37 : extends<basic_expr<tag::terminal, term<T>, 0>, literal<T, Domain>, Domain>
Chris@16 38 {
Chris@16 39 private:
Chris@16 40 typedef basic_expr<tag::terminal, term<T>, 0> terminal_type;
Chris@16 41 typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
Chris@16 42 typedef literal<T, Domain> literal_t;
Chris@16 43
Chris@16 44 public:
Chris@16 45 typedef typename detail::term_traits<T>::value_type value_type;
Chris@16 46 typedef typename detail::term_traits<T>::reference reference;
Chris@16 47 typedef typename detail::term_traits<T>::const_reference const_reference;
Chris@16 48
Chris@16 49 literal()
Chris@16 50 : base_type(terminal_type::make(T()))
Chris@16 51 {}
Chris@16 52
Chris@16 53 template<typename U>
Chris@16 54 literal(U &u)
Chris@16 55 : base_type(terminal_type::make(u))
Chris@16 56 {}
Chris@16 57
Chris@16 58 template<typename U>
Chris@16 59 literal(U const &u)
Chris@16 60 : base_type(terminal_type::make(u))
Chris@16 61 {}
Chris@16 62
Chris@16 63 template<typename U>
Chris@16 64 literal(literal<U, Domain> const &u)
Chris@16 65 : base_type(terminal_type::make(u.get()))
Chris@16 66 {}
Chris@16 67
Chris@16 68 BOOST_PROTO_EXTENDS_USING_ASSIGN(literal_t)
Chris@16 69
Chris@16 70 reference get()
Chris@16 71 {
Chris@16 72 return proto::value(*this);
Chris@16 73 }
Chris@16 74
Chris@16 75 const_reference get() const
Chris@16 76 {
Chris@16 77 return proto::value(*this);
Chris@16 78 }
Chris@16 79 };
Chris@16 80 }
Chris@16 81
Chris@16 82 /// \brief A helper function for creating a \c literal\<\> wrapper.
Chris@16 83 /// \param t The object to wrap.
Chris@16 84 /// \return literal\<T &\>(t)
Chris@16 85 /// \attention The returned value holds the argument by reference.
Chris@16 86 /// \throw nothrow
Chris@16 87 template<typename T>
Chris@16 88 inline literal<T &> const lit(T &t)
Chris@16 89 {
Chris@16 90 return literal<T &>(t);
Chris@16 91 }
Chris@16 92
Chris@16 93 /// \overload
Chris@16 94 ///
Chris@16 95 template<typename T>
Chris@16 96 inline literal<T const &> const lit(T const &t)
Chris@16 97 {
Chris@16 98 #ifdef BOOST_MSVC
Chris@16 99 #pragma warning(push)
Chris@16 100 #pragma warning(disable: 4180) // warning C4180: qualifier applied to function type has no meaning; ignored
Chris@16 101 #endif
Chris@16 102
Chris@16 103 return literal<T const &>(t);
Chris@16 104
Chris@16 105 #ifdef BOOST_MSVC
Chris@16 106 #pragma warning(pop)
Chris@16 107 #endif
Chris@16 108 }
Chris@16 109
Chris@16 110 }}
Chris@16 111
Chris@16 112 #endif