File indexing completed on 2025-01-30 09:58:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
0011 #define BOOST_PROTO_LITERAL_HPP_EAN_01_03_2007
0012
0013 #include <boost/config.hpp>
0014 #include <boost/proto/proto_fwd.hpp>
0015 #include <boost/proto/expr.hpp>
0016 #include <boost/proto/traits.hpp>
0017 #include <boost/proto/extends.hpp>
0018
0019 namespace boost { namespace proto
0020 {
0021 namespace utility
0022 {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 template<
0033 typename T
0034 , typename Domain
0035 >
0036 struct literal
0037 : extends<basic_expr<tag::terminal, term<T>, 0>, literal<T, Domain>, Domain>
0038 {
0039 private:
0040 typedef basic_expr<tag::terminal, term<T>, 0> terminal_type;
0041 typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
0042 typedef literal<T, Domain> literal_t;
0043
0044 public:
0045 typedef typename detail::term_traits<T>::value_type value_type;
0046 typedef typename detail::term_traits<T>::reference reference;
0047 typedef typename detail::term_traits<T>::const_reference const_reference;
0048
0049 literal()
0050 : base_type(terminal_type::make(T()))
0051 {}
0052
0053 #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
0054 literal(literal const &) = default;
0055 #endif
0056
0057 template<typename U>
0058 literal(U &u)
0059 : base_type(terminal_type::make(u))
0060 {}
0061
0062 template<typename U>
0063 literal(U const &u)
0064 : base_type(terminal_type::make(u))
0065 {}
0066
0067 template<typename U>
0068 literal(literal<U, Domain> const &u)
0069 : base_type(terminal_type::make(u.get()))
0070 {}
0071
0072 BOOST_PROTO_EXTENDS_USING_ASSIGN(literal_t)
0073
0074 reference get()
0075 {
0076 return proto::value(*this);
0077 }
0078
0079 const_reference get() const
0080 {
0081 return proto::value(*this);
0082 }
0083 };
0084 }
0085
0086
0087
0088
0089
0090
0091 template<typename T>
0092 inline literal<T &> const lit(T &t)
0093 {
0094 return literal<T &>(t);
0095 }
0096
0097
0098
0099 template<typename T>
0100 inline literal<T const &> const lit(T const &t)
0101 {
0102 #ifdef BOOST_MSVC
0103 #pragma warning(push)
0104 #pragma warning(disable: 4180)
0105 #endif
0106
0107 return literal<T const &>(t);
0108
0109 #ifdef BOOST_MSVC
0110 #pragma warning(pop)
0111 #endif
0112 }
0113
0114 }}
0115
0116 #endif