File indexing completed on 2025-12-16 10:07:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_PROTO_ARG_TRAITS_HPP_EAN_04_01_2005
0012 #define BOOST_PROTO_ARG_TRAITS_HPP_EAN_04_01_2005
0013
0014 #include <boost/config.hpp>
0015 #include <boost/detail/workaround.hpp>
0016 #include <boost/preprocessor/iteration/iterate.hpp>
0017 #include <boost/preprocessor/repetition/enum.hpp>
0018 #include <boost/preprocessor/repetition/enum_params.hpp>
0019 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0020 #include <boost/preprocessor/repetition/repeat.hpp>
0021 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0022 #include <boost/preprocessor/facilities/intercept.hpp>
0023 #include <boost/preprocessor/arithmetic/sub.hpp>
0024 #include <boost/static_assert.hpp>
0025 #include <boost/mpl/bool.hpp>
0026 #include <boost/proto/detail/template_arity.hpp>
0027 #include <boost/type_traits/is_pod.hpp>
0028 #include <boost/type_traits/is_same.hpp>
0029 #include <boost/type_traits/add_const.hpp>
0030 #include <boost/proto/proto_fwd.hpp>
0031 #include <boost/proto/args.hpp>
0032 #include <boost/proto/domain.hpp>
0033 #include <boost/proto/transform/pass_through.hpp>
0034
0035 #if defined(_MSC_VER)
0036 # pragma warning(push)
0037 # if BOOST_WORKAROUND( BOOST_MSVC, >= 1400 )
0038 # pragma warning(disable: 4180)
0039 # endif
0040 # pragma warning(disable : 4714)
0041 #endif
0042
0043 namespace boost { namespace proto
0044 {
0045 namespace detail
0046 {
0047 template<typename T, typename Void = void>
0048 struct if_vararg
0049 {};
0050
0051 template<typename T>
0052 struct if_vararg<T, typename T::proto_is_vararg_>
0053 : T
0054 {};
0055
0056 template<typename T, typename Void = void>
0057 struct is_callable2_
0058 : mpl::false_
0059 {};
0060
0061 template<typename T>
0062 struct is_callable2_<T, typename T::proto_is_callable_>
0063 : mpl::true_
0064 {};
0065
0066 template<typename T BOOST_PROTO_TEMPLATE_ARITY_PARAM(long Arity = boost::proto::detail::template_arity<T>::value)>
0067 struct is_callable_
0068 : is_callable2_<T>
0069 {};
0070
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 template<typename T>
0094 struct is_callable
0095 : proto::detail::is_callable_<T>
0096 {};
0097
0098
0099
0100 template<>
0101 struct is_callable<proto::_>
0102 : mpl::true_
0103 {};
0104
0105
0106
0107 template<>
0108 struct is_callable<proto::callable>
0109 : mpl::false_
0110 {};
0111
0112
0113
0114 template<typename PrimitiveTransform, typename X>
0115 struct is_callable<proto::transform<PrimitiveTransform, X> >
0116 : mpl::false_
0117 {};
0118
0119 #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0)
0120
0121 template<typename Tag, typename Args, long N>
0122 struct is_callable<proto::expr<Tag, Args, N> >
0123 : mpl::false_
0124 {};
0125
0126
0127 template<typename Tag, typename Args, long N>
0128 struct is_callable<proto::basic_expr<Tag, Args, N> >
0129 : mpl::false_
0130 {};
0131 #endif
0132
0133 namespace detail
0134 {
0135 template<typename T, typename Void >
0136 struct is_transform_
0137 : mpl::false_
0138 {};
0139
0140 template<typename T>
0141 struct is_transform_<T, typename T::proto_is_transform_>
0142 : mpl::true_
0143 {};
0144 }
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 template<typename T>
0162 struct is_transform
0163 : proto::detail::is_transform_<T>
0164 {};
0165
0166 namespace detail
0167 {
0168 template<typename T, typename Void >
0169 struct is_aggregate_
0170 : is_pod<T>
0171 {};
0172
0173 template<typename Tag, typename Args, long N>
0174 struct is_aggregate_<proto::expr<Tag, Args, N>, void>
0175 : mpl::true_
0176 {};
0177
0178 template<typename Tag, typename Args, long N>
0179 struct is_aggregate_<proto::basic_expr<Tag, Args, N>, void>
0180 : mpl::true_
0181 {};
0182
0183 template<typename T>
0184 struct is_aggregate_<T, typename T::proto_is_aggregate_>
0185 : mpl::true_
0186 {};
0187 }
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198 template<typename T>
0199 struct is_aggregate
0200 : proto::detail::is_aggregate_<T>
0201 {};
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212 template<typename T, typename Void >
0213 struct is_expr
0214 : mpl::false_
0215 {};
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226 template<typename T>
0227 struct is_expr<T, typename T::proto_is_expr_>
0228 : mpl::true_
0229 {};
0230
0231 template<typename T>
0232 struct is_expr<T &, void>
0233 : is_expr<T>
0234 {};
0235
0236
0237
0238 template<typename Expr>
0239 struct tag_of
0240 {
0241 typedef typename Expr::proto_tag type;
0242 };
0243
0244 template<typename Expr>
0245 struct tag_of<Expr &>
0246 {
0247 typedef typename Expr::proto_tag type;
0248 };
0249
0250
0251
0252 template<typename Expr>
0253 struct arity_of
0254 : Expr::proto_arity
0255 {};
0256
0257 template<typename Expr>
0258 struct arity_of<Expr &>
0259 : Expr::proto_arity
0260 {};
0261
0262 namespace result_of
0263 {
0264
0265
0266 template<typename T, typename Domain >
0267 struct as_expr
0268 {
0269 typedef typename Domain::template as_expr<T>::result_type type;
0270 };
0271
0272
0273
0274 template<typename T, typename Domain >
0275 struct as_child
0276 {
0277 typedef typename Domain::template as_child<T>::result_type type;
0278 };
0279
0280
0281
0282
0283
0284
0285 template<typename Expr, typename N >
0286 struct child
0287 : child_c<Expr, N::value>
0288 {};
0289
0290
0291
0292
0293 template<typename Expr>
0294 struct value
0295 {
0296
0297 BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
0298
0299
0300
0301 typedef typename Expr::proto_child0 value_type;
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312 typedef typename detail::term_traits<typename Expr::proto_child0>::value_type type;
0313 };
0314
0315 template<typename Expr>
0316 struct value<Expr &>
0317 {
0318
0319 BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
0320
0321
0322
0323 typedef typename Expr::proto_child0 value_type;
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334 typedef typename detail::term_traits<typename Expr::proto_child0>::reference type;
0335 };
0336
0337 template<typename Expr>
0338 struct value<Expr const &>
0339 {
0340
0341 BOOST_STATIC_ASSERT(0 == Expr::proto_arity_c);
0342
0343
0344
0345 typedef typename Expr::proto_child0 value_type;
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356 typedef typename detail::term_traits<typename Expr::proto_child0>::const_reference type;
0357 };
0358
0359
0360
0361
0362
0363
0364 template<typename Expr>
0365 struct left
0366 : child_c<Expr, 0>
0367 {};
0368
0369
0370
0371
0372
0373
0374 template<typename Expr>
0375 struct right
0376 : child_c<Expr, 1>
0377 {};
0378
0379 }
0380
0381
0382
0383
0384 template<typename T>
0385 struct terminal
0386 : proto::transform<terminal<T>, int>
0387 {
0388 typedef proto::expr<proto::tag::terminal, term<T>, 0> type;
0389 typedef proto::basic_expr<proto::tag::terminal, term<T>, 0> proto_grammar;
0390
0391 template<typename Expr, typename State, typename Data>
0392 struct impl : transform_impl<Expr, State, Data>
0393 {
0394 typedef Expr result_type;
0395
0396
0397
0398
0399
0400 BOOST_FORCEINLINE
0401 BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param)
0402 operator ()(
0403 typename impl::expr_param e
0404 , typename impl::state_param
0405 , typename impl::data_param
0406 ) const
0407 {
0408 return e;
0409 }
0410 };
0411
0412
0413 typedef proto::tag::terminal proto_tag;
0414
0415 typedef T proto_child0;
0416 };
0417
0418
0419
0420
0421
0422 template<typename T, typename U, typename V>
0423 struct if_else_
0424 : proto::transform<if_else_<T, U, V>, int>
0425 {
0426 typedef proto::expr<proto::tag::if_else_, list3<T, U, V>, 3> type;
0427 typedef proto::basic_expr<proto::tag::if_else_, list3<T, U, V>, 3> proto_grammar;
0428
0429 template<typename Expr, typename State, typename Data>
0430 struct impl
0431 : detail::pass_through_impl<if_else_, deduce_domain, Expr, State, Data>
0432 {};
0433
0434
0435 typedef proto::tag::if_else_ proto_tag;
0436
0437 typedef T proto_child0;
0438
0439 typedef U proto_child1;
0440
0441 typedef V proto_child2;
0442 };
0443
0444
0445
0446
0447
0448
0449
0450
0451 template<typename Tag, typename T>
0452 struct nullary_expr
0453 : proto::transform<nullary_expr<Tag, T>, int>
0454 {
0455 typedef proto::expr<Tag, term<T>, 0> type;
0456 typedef proto::basic_expr<Tag, term<T>, 0> proto_grammar;
0457
0458 template<typename Expr, typename State, typename Data>
0459 struct impl : transform_impl<Expr, State, Data>
0460 {
0461 typedef Expr result_type;
0462
0463
0464
0465
0466
0467 BOOST_FORCEINLINE
0468 BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param)
0469 operator ()(
0470 typename impl::expr_param e
0471 , typename impl::state_param
0472 , typename impl::data_param
0473 ) const
0474 {
0475 return e;
0476 }
0477 };
0478
0479
0480 typedef Tag proto_tag;
0481
0482 typedef T proto_child0;
0483 };
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493 template<typename Tag, typename T>
0494 struct unary_expr
0495 : proto::transform<unary_expr<Tag, T>, int>
0496 {
0497 typedef proto::expr<Tag, list1<T>, 1> type;
0498 typedef proto::basic_expr<Tag, list1<T>, 1> proto_grammar;
0499
0500 template<typename Expr, typename State, typename Data>
0501 struct impl
0502 : detail::pass_through_impl<unary_expr, deduce_domain, Expr, State, Data>
0503 {};
0504
0505
0506 typedef Tag proto_tag;
0507
0508 typedef T proto_child0;
0509 };
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519 template<typename Tag, typename T, typename U>
0520 struct binary_expr
0521 : proto::transform<binary_expr<Tag, T, U>, int>
0522 {
0523 typedef proto::expr<Tag, list2<T, U>, 2> type;
0524 typedef proto::basic_expr<Tag, list2<T, U>, 2> proto_grammar;
0525
0526 template<typename Expr, typename State, typename Data>
0527 struct impl
0528 : detail::pass_through_impl<binary_expr, deduce_domain, Expr, State, Data>
0529 {};
0530
0531
0532 typedef Tag proto_tag;
0533
0534 typedef T proto_child0;
0535
0536 typedef U proto_child1;
0537 };
0538
0539 #define BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(Op) \
0540 template<typename T> \
0541 struct Op \
0542 : proto::transform<Op<T>, int> \
0543 { \
0544 typedef proto::expr<proto::tag::Op, list1<T>, 1> type; \
0545 typedef proto::basic_expr<proto::tag::Op, list1<T>, 1> proto_grammar; \
0546 \
0547 template<typename Expr, typename State, typename Data> \
0548 struct impl \
0549 : detail::pass_through_impl<Op, deduce_domain, Expr, State, Data> \
0550 {}; \
0551 \
0552 typedef proto::tag::Op proto_tag; \
0553 typedef T proto_child0; \
0554 }; \
0555
0556
0557 #define BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(Op) \
0558 template<typename T, typename U> \
0559 struct Op \
0560 : proto::transform<Op<T, U>, int> \
0561 { \
0562 typedef proto::expr<proto::tag::Op, list2<T, U>, 2> type; \
0563 typedef proto::basic_expr<proto::tag::Op, list2<T, U>, 2> proto_grammar; \
0564 \
0565 template<typename Expr, typename State, typename Data> \
0566 struct impl \
0567 : detail::pass_through_impl<Op, deduce_domain, Expr, State, Data> \
0568 {}; \
0569 \
0570 typedef proto::tag::Op proto_tag; \
0571 typedef T proto_child0; \
0572 typedef U proto_child1; \
0573 }; \
0574
0575
0576 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(unary_plus)
0577 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(negate)
0578 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(dereference)
0579 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(complement)
0580 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(address_of)
0581 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(logical_not)
0582 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_inc)
0583 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(pre_dec)
0584 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_inc)
0585 BOOST_PROTO_DEFINE_UNARY_METAFUNCTION(post_dec)
0586
0587 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left)
0588 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right)
0589 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies)
0590 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides)
0591 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus)
0592 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus)
0593 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus)
0594 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less)
0595 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater)
0596 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(less_equal)
0597 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(greater_equal)
0598 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(equal_to)
0599 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(not_equal_to)
0600 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_or)
0601 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(logical_and)
0602 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or)
0603 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and)
0604 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor)
0605 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(comma)
0606 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(mem_ptr)
0607 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(assign)
0608 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_left_assign)
0609 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(shift_right_assign)
0610 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(multiplies_assign)
0611 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(divides_assign)
0612 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(modulus_assign)
0613 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(plus_assign)
0614 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(minus_assign)
0615 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_or_assign)
0616 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_and_assign)
0617 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(bitwise_xor_assign)
0618 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(subscript)
0619 BOOST_PROTO_DEFINE_BINARY_METAFUNCTION(member)
0620
0621 #undef BOOST_PROTO_DEFINE_UNARY_METAFUNCTION
0622 #undef BOOST_PROTO_DEFINE_BINARY_METAFUNCTION
0623
0624 #include <boost/proto/detail/traits.hpp>
0625
0626 namespace functional
0627 {
0628
0629
0630 template<typename Domain >
0631 struct as_expr
0632 {
0633 BOOST_PROTO_CALLABLE()
0634
0635 template<typename Sig>
0636 struct result;
0637
0638 template<typename This, typename T>
0639 struct result<This(T)>
0640 {
0641 typedef typename Domain::template as_expr<T>::result_type type;
0642 };
0643
0644 template<typename This, typename T>
0645 struct result<This(T &)>
0646 {
0647 typedef typename Domain::template as_expr<T>::result_type type;
0648 };
0649
0650
0651
0652
0653
0654 template<typename T>
0655 BOOST_FORCEINLINE
0656 typename add_const<typename result<as_expr(T &)>::type>::type
0657 operator ()(T &t) const
0658 {
0659 return typename Domain::template as_expr<T>()(t);
0660 }
0661
0662
0663
0664 template<typename T>
0665 BOOST_FORCEINLINE
0666 typename add_const<typename result<as_expr(T const &)>::type>::type
0667 operator ()(T const &t) const
0668 {
0669 return typename Domain::template as_expr<T const>()(t);
0670 }
0671
0672 #if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
0673 template<typename T, std::size_t N_>
0674 BOOST_FORCEINLINE
0675 typename add_const<typename result<as_expr(T (&)[N_])>::type>::type
0676 operator ()(T (&t)[N_]) const
0677 {
0678 return typename Domain::template as_expr<T[N_]>()(t);
0679 }
0680
0681 template<typename T, std::size_t N_>
0682 BOOST_FORCEINLINE
0683 typename add_const<typename result<as_expr(T const (&)[N_])>::type>::type
0684 operator ()(T const (&t)[N_]) const
0685 {
0686 return typename Domain::template as_expr<T const[N_]>()(t);
0687 }
0688 #endif
0689 };
0690
0691
0692
0693 template<typename Domain >
0694 struct as_child
0695 {
0696 BOOST_PROTO_CALLABLE()
0697
0698 template<typename Sig>
0699 struct result;
0700
0701 template<typename This, typename T>
0702 struct result<This(T)>
0703 {
0704 typedef typename Domain::template as_child<T>::result_type type;
0705 };
0706
0707 template<typename This, typename T>
0708 struct result<This(T &)>
0709 {
0710 typedef typename Domain::template as_child<T>::result_type type;
0711 };
0712
0713
0714
0715
0716
0717 template<typename T>
0718 BOOST_FORCEINLINE
0719 typename add_const<typename result<as_child(T &)>::type>::type
0720 operator ()(T &t) const
0721 {
0722 return typename Domain::template as_child<T>()(t);
0723 }
0724
0725
0726
0727 template<typename T>
0728 BOOST_FORCEINLINE
0729 typename add_const<typename result<as_child(T const &)>::type>::type
0730 operator ()(T const &t) const
0731 {
0732 return typename Domain::template as_child<T const>()(t);
0733 }
0734 };
0735
0736
0737
0738 template<long N>
0739 struct child_c
0740 {
0741 BOOST_PROTO_CALLABLE()
0742
0743 template<typename Sig>
0744 struct result;
0745
0746 template<typename This, typename Expr>
0747 struct result<This(Expr)>
0748 {
0749 typedef typename result_of::child_c<Expr, N>::type type;
0750 };
0751
0752
0753
0754
0755
0756
0757
0758 template<typename Expr>
0759 BOOST_FORCEINLINE
0760 typename result_of::child_c<Expr &, N>::type
0761 operator ()(Expr &e) const
0762 {
0763 return result_of::child_c<Expr &, N>::call(e);
0764 }
0765
0766
0767
0768 template<typename Expr>
0769 BOOST_FORCEINLINE
0770 typename result_of::child_c<Expr const &, N>::type
0771 operator ()(Expr const &e) const
0772 {
0773 return result_of::child_c<Expr const &, N>::call(e);
0774 }
0775 };
0776
0777
0778
0779
0780
0781
0782
0783 template<typename N >
0784 struct child
0785 {
0786 BOOST_PROTO_CALLABLE()
0787
0788 template<typename Sig>
0789 struct result;
0790
0791 template<typename This, typename Expr>
0792 struct result<This(Expr)>
0793 {
0794 typedef typename result_of::child<Expr, N>::type type;
0795 };
0796
0797
0798
0799
0800
0801
0802
0803 template<typename Expr>
0804 BOOST_FORCEINLINE
0805 typename result_of::child<Expr &, N>::type
0806 operator ()(Expr &e) const
0807 {
0808 return result_of::child<Expr &, N>::call(e);
0809 }
0810
0811
0812
0813 template<typename Expr>
0814 BOOST_FORCEINLINE
0815 typename result_of::child<Expr const &, N>::type
0816 operator ()(Expr const &e) const
0817 {
0818 return result_of::child<Expr const &, N>::call(e);
0819 }
0820 };
0821
0822
0823
0824 struct value
0825 {
0826 BOOST_PROTO_CALLABLE()
0827
0828 template<typename Sig>
0829 struct result;
0830
0831 template<typename This, typename Expr>
0832 struct result<This(Expr)>
0833 {
0834 typedef typename result_of::value<Expr>::type type;
0835 };
0836
0837
0838
0839
0840
0841
0842
0843 template<typename Expr>
0844 BOOST_FORCEINLINE
0845 typename result_of::value<Expr &>::type
0846 operator ()(Expr &e) const
0847 {
0848 return e.proto_base().child0;
0849 }
0850
0851
0852
0853 template<typename Expr>
0854 BOOST_FORCEINLINE
0855 typename result_of::value<Expr const &>::type
0856 operator ()(Expr const &e) const
0857 {
0858 return e.proto_base().child0;
0859 }
0860 };
0861
0862
0863
0864 struct left
0865 {
0866 BOOST_PROTO_CALLABLE()
0867
0868 template<typename Sig>
0869 struct result;
0870
0871 template<typename This, typename Expr>
0872 struct result<This(Expr)>
0873 {
0874 typedef typename result_of::left<Expr>::type type;
0875 };
0876
0877
0878
0879
0880
0881
0882
0883 template<typename Expr>
0884 BOOST_FORCEINLINE
0885 typename result_of::left<Expr &>::type
0886 operator ()(Expr &e) const
0887 {
0888 return e.proto_base().child0;
0889 }
0890
0891
0892
0893 template<typename Expr>
0894 BOOST_FORCEINLINE
0895 typename result_of::left<Expr const &>::type
0896 operator ()(Expr const &e) const
0897 {
0898 return e.proto_base().child0;
0899 }
0900 };
0901
0902
0903
0904 struct right
0905 {
0906 BOOST_PROTO_CALLABLE()
0907
0908 template<typename Sig>
0909 struct result;
0910
0911 template<typename This, typename Expr>
0912 struct result<This(Expr)>
0913 {
0914 typedef typename result_of::right<Expr>::type type;
0915 };
0916
0917
0918
0919
0920
0921
0922
0923 template<typename Expr>
0924 BOOST_FORCEINLINE
0925 typename result_of::right<Expr &>::type
0926 operator ()(Expr &e) const
0927 {
0928 return e.proto_base().child1;
0929 }
0930
0931 template<typename Expr>
0932 BOOST_FORCEINLINE
0933 typename result_of::right<Expr const &>::type
0934 operator ()(Expr const &e) const
0935 {
0936 return e.proto_base().child1;
0937 }
0938 };
0939
0940 }
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963 template<typename T>
0964 BOOST_FORCEINLINE
0965 typename add_const<typename result_of::as_expr<T, default_domain>::type>::type
0966 as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T))
0967 {
0968 return default_domain::as_expr<T>()(t);
0969 }
0970
0971
0972
0973 template<typename T>
0974 BOOST_FORCEINLINE
0975 typename add_const<typename result_of::as_expr<T const, default_domain>::type>::type
0976 as_expr(T const &t)
0977 {
0978 return default_domain::as_expr<T const>()(t);
0979 }
0980
0981
0982
0983 template<typename Domain, typename T>
0984 BOOST_FORCEINLINE
0985 typename add_const<typename result_of::as_expr<T, Domain>::type>::type
0986 as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T))
0987 {
0988 return typename Domain::template as_expr<T>()(t);
0989 }
0990
0991
0992
0993 template<typename Domain, typename T>
0994 BOOST_FORCEINLINE
0995 typename add_const<typename result_of::as_expr<T const, Domain>::type>::type
0996 as_expr(T const &t)
0997 {
0998 return typename Domain::template as_expr<T const>()(t);
0999 }
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020 template<typename T>
1021 BOOST_FORCEINLINE
1022 typename add_const<typename result_of::as_child<T, default_domain>::type>::type
1023 as_child(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T))
1024 {
1025 return default_domain::as_child<T>()(t);
1026 }
1027
1028
1029
1030 template<typename T>
1031 BOOST_FORCEINLINE
1032 typename add_const<typename result_of::as_child<T const, default_domain>::type>::type
1033 as_child(T const &t)
1034 {
1035 return default_domain::as_child<T const>()(t);
1036 }
1037
1038
1039
1040 template<typename Domain, typename T>
1041 BOOST_FORCEINLINE
1042 typename add_const<typename result_of::as_child<T, Domain>::type>::type
1043 as_child(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T) BOOST_PROTO_DISABLE_IF_IS_FUNCTION(T))
1044 {
1045 return typename Domain::template as_child<T>()(t);
1046 }
1047
1048
1049
1050 template<typename Domain, typename T>
1051 BOOST_FORCEINLINE
1052 typename add_const<typename result_of::as_child<T const, Domain>::type>::type
1053 as_child(T const &t)
1054 {
1055 return typename Domain::template as_child<T const>()(t);
1056 }
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071 template<typename N, typename Expr>
1072 BOOST_FORCEINLINE
1073 typename result_of::child<Expr &, N>::type
1074 child(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
1075 {
1076 return result_of::child<Expr &, N>::call(e);
1077 }
1078
1079
1080
1081 template<typename N, typename Expr>
1082 BOOST_FORCEINLINE
1083 typename result_of::child<Expr const &, N>::type
1084 child(Expr const &e)
1085 {
1086 return result_of::child<Expr const &, N>::call(e);
1087 }
1088
1089
1090
1091 template<typename Expr2>
1092 BOOST_FORCEINLINE
1093 typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::reference
1094 child(Expr2 &expr2 BOOST_PROTO_DISABLE_IF_IS_CONST(Expr2))
1095 {
1096 return expr2.proto_base().child0;
1097 }
1098
1099
1100
1101 template<typename Expr2>
1102 BOOST_FORCEINLINE
1103 typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::const_reference
1104 child(Expr2 const &expr2)
1105 {
1106 return expr2.proto_base().child0;
1107 }
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119 template<long N, typename Expr>
1120 BOOST_FORCEINLINE
1121 typename result_of::child_c<Expr &, N>::type
1122 child_c(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
1123 {
1124 return result_of::child_c<Expr &, N>::call(e);
1125 }
1126
1127
1128
1129 template<long N, typename Expr>
1130 BOOST_FORCEINLINE
1131 typename result_of::child_c<Expr const &, N>::type
1132 child_c(Expr const &e)
1133 {
1134 return result_of::child_c<Expr const &, N>::call(e);
1135 }
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148 template<typename Expr>
1149 BOOST_FORCEINLINE
1150 typename result_of::value<Expr &>::type
1151 value(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
1152 {
1153 return e.proto_base().child0;
1154 }
1155
1156
1157
1158 template<typename Expr>
1159 BOOST_FORCEINLINE
1160 typename result_of::value<Expr const &>::type
1161 value(Expr const &e)
1162 {
1163 return e.proto_base().child0;
1164 }
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177 template<typename Expr>
1178 BOOST_FORCEINLINE
1179 typename result_of::left<Expr &>::type
1180 left(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
1181 {
1182 return e.proto_base().child0;
1183 }
1184
1185
1186
1187 template<typename Expr>
1188 BOOST_FORCEINLINE
1189 typename result_of::left<Expr const &>::type
1190 left(Expr const &e)
1191 {
1192 return e.proto_base().child0;
1193 }
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206 template<typename Expr>
1207 BOOST_FORCEINLINE
1208 typename result_of::right<Expr &>::type
1209 right(Expr &e BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
1210 {
1211 return e.proto_base().child1;
1212 }
1213
1214
1215
1216 template<typename Expr>
1217 BOOST_FORCEINLINE
1218 typename result_of::right<Expr const &>::type
1219 right(Expr const &e)
1220 {
1221 return e.proto_base().child1;
1222 }
1223
1224
1225
1226 template<typename Domain>
1227 struct is_callable<functional::as_expr<Domain> >
1228 : mpl::true_
1229 {};
1230
1231
1232
1233 template<typename Domain>
1234 struct is_callable<functional::as_child<Domain> >
1235 : mpl::true_
1236 {};
1237
1238
1239
1240 template<long N>
1241 struct is_callable<functional::child_c<N> >
1242 : mpl::true_
1243 {};
1244
1245
1246
1247 template<typename N>
1248 struct is_callable<functional::child<N> >
1249 : mpl::true_
1250 {};
1251
1252 }}
1253
1254 #if defined(_MSC_VER)
1255 # pragma warning(pop)
1256 #endif
1257
1258 #endif