File indexing completed on 2025-01-18 09:53:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_XPRESSIVE_ACTIONS_HPP_EAN_03_22_2007
0010 #define BOOST_XPRESSIVE_ACTIONS_HPP_EAN_03_22_2007
0011
0012
0013 #if defined(_MSC_VER)
0014 # pragma once
0015 #endif
0016
0017 #include <boost/config.hpp>
0018 #include <boost/preprocessor/punctuation/comma_if.hpp>
0019 #include <boost/ref.hpp>
0020 #include <boost/mpl/if.hpp>
0021 #include <boost/mpl/or.hpp>
0022 #include <boost/mpl/int.hpp>
0023 #include <boost/mpl/assert.hpp>
0024 #include <boost/noncopyable.hpp>
0025 #include <boost/lexical_cast.hpp>
0026 #include <boost/throw_exception.hpp>
0027 #include <boost/utility/enable_if.hpp>
0028 #include <boost/type_traits/is_same.hpp>
0029 #include <boost/type_traits/is_const.hpp>
0030 #include <boost/type_traits/is_integral.hpp>
0031 #include <boost/type_traits/decay.hpp>
0032 #include <boost/type_traits/remove_cv.hpp>
0033 #include <boost/type_traits/remove_reference.hpp>
0034 #include <boost/range/iterator_range.hpp>
0035 #include <boost/xpressive/detail/detail_fwd.hpp>
0036 #include <boost/xpressive/detail/core/state.hpp>
0037 #include <boost/xpressive/detail/core/matcher/attr_matcher.hpp>
0038 #include <boost/xpressive/detail/core/matcher/attr_end_matcher.hpp>
0039 #include <boost/xpressive/detail/core/matcher/attr_begin_matcher.hpp>
0040 #include <boost/xpressive/detail/core/matcher/predicate_matcher.hpp>
0041 #include <boost/xpressive/detail/utility/ignore_unused.hpp>
0042 #include <boost/xpressive/detail/static/type_traits.hpp>
0043
0044
0045 #include <boost/typeof/std/map.hpp>
0046 #include <boost/typeof/std/string.hpp>
0047
0048
0049 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
0050 # include <boost/proto/core.hpp>
0051 # include <boost/proto/transform.hpp>
0052 # include <boost/xpressive/detail/core/matcher/action_matcher.hpp>
0053 #endif
0054
0055 #if BOOST_MSVC
0056 #pragma warning(push)
0057 #pragma warning(disable : 4510)
0058 #pragma warning(disable : 4512)
0059 #pragma warning(disable : 4610)
0060 #endif
0061
0062 namespace boost { namespace xpressive
0063 {
0064
0065 namespace detail
0066 {
0067 template<typename T, typename U>
0068 struct action_arg
0069 {
0070 typedef T type;
0071 typedef typename add_reference<T>::type reference;
0072
0073 reference cast(void *pv) const
0074 {
0075 return *static_cast<typename remove_reference<T>::type *>(pv);
0076 }
0077 };
0078
0079 template<typename T>
0080 struct value_wrapper
0081 : private noncopyable
0082 {
0083 value_wrapper()
0084 : value()
0085 {}
0086
0087 value_wrapper(T const &t)
0088 : value(t)
0089 {}
0090
0091 T value;
0092 };
0093
0094 struct check_tag
0095 {};
0096
0097 struct BindArg
0098 {
0099 BOOST_PROTO_CALLABLE()
0100 template<typename Sig>
0101 struct result {};
0102
0103 template<typename This, typename MatchResults, typename Expr>
0104 struct result<This(MatchResults, Expr)>
0105 {
0106 typedef Expr type;
0107 };
0108
0109 template<typename MatchResults, typename Expr>
0110 Expr const & operator ()(MatchResults &what, Expr const &expr) const
0111 {
0112 what.let(expr);
0113 return expr;
0114 }
0115 };
0116
0117 struct let_tag
0118 {};
0119
0120
0121 struct BindArgs
0122 : proto::function<
0123 proto::terminal<let_tag>
0124 , proto::vararg<
0125 proto::when<
0126 proto::assign<proto::_, proto::_>
0127 , proto::call<BindArg(proto::_data, proto::_)>
0128 >
0129 >
0130 >
0131 {};
0132
0133 struct let_domain
0134 : boost::proto::domain<boost::proto::pod_generator<let_> >
0135 {};
0136
0137 template<typename Expr>
0138 struct let_
0139 {
0140 BOOST_PROTO_BASIC_EXTENDS(Expr, let_<Expr>, let_domain)
0141 BOOST_PROTO_EXTENDS_FUNCTION()
0142 };
0143
0144 template<typename Args, typename BidiIter>
0145 void bind_args(let_<Args> const &args, match_results<BidiIter> &what)
0146 {
0147 BindArgs()(args, 0, what);
0148 }
0149
0150 typedef boost::proto::functional::make_expr<proto::tag::function, proto::default_domain> make_function;
0151 }
0152
0153 namespace op
0154 {
0155
0156 struct at
0157 {
0158 BOOST_PROTO_CALLABLE()
0159 template<typename Sig>
0160 struct result {};
0161
0162 template<typename This, typename Cont, typename Idx>
0163 struct result<This(Cont &, Idx)>
0164 {
0165 typedef typename Cont::reference type;
0166 };
0167
0168 template<typename This, typename Cont, typename Idx>
0169 struct result<This(Cont const &, Idx)>
0170 {
0171 typedef typename Cont::const_reference type;
0172 };
0173
0174 template<typename This, typename Cont, typename Idx>
0175 struct result<This(Cont, Idx)>
0176 {
0177 typedef typename Cont::const_reference type;
0178 };
0179
0180
0181
0182
0183
0184 template<typename Cont, typename Idx>
0185 typename Cont::reference operator()(Cont &c, Idx idx BOOST_PROTO_DISABLE_IF_IS_CONST(Cont)) const
0186 {
0187 return c[idx];
0188 }
0189
0190
0191
0192 template<typename Cont, typename Idx>
0193 typename Cont::const_reference operator()(Cont const &c, Idx idx) const
0194 {
0195 return c[idx];
0196 }
0197 };
0198
0199
0200 struct push
0201 {
0202 BOOST_PROTO_CALLABLE()
0203 typedef void result_type;
0204
0205
0206
0207
0208
0209 template<typename Sequence, typename Value>
0210 void operator()(Sequence &seq, Value const &val) const
0211 {
0212 seq.push(val);
0213 }
0214 };
0215
0216
0217 struct push_back
0218 {
0219 BOOST_PROTO_CALLABLE()
0220 typedef void result_type;
0221
0222
0223
0224
0225
0226 template<typename Sequence, typename Value>
0227 void operator()(Sequence &seq, Value const &val) const
0228 {
0229 seq.push_back(val);
0230 }
0231 };
0232
0233
0234 struct push_front
0235 {
0236 BOOST_PROTO_CALLABLE()
0237 typedef void result_type;
0238
0239
0240
0241
0242
0243 template<typename Sequence, typename Value>
0244 void operator()(Sequence &seq, Value const &val) const
0245 {
0246 seq.push_front(val);
0247 }
0248 };
0249
0250
0251 struct pop
0252 {
0253 BOOST_PROTO_CALLABLE()
0254 typedef void result_type;
0255
0256
0257
0258
0259 template<typename Sequence>
0260 void operator()(Sequence &seq) const
0261 {
0262 seq.pop();
0263 }
0264 };
0265
0266
0267 struct pop_back
0268 {
0269 BOOST_PROTO_CALLABLE()
0270 typedef void result_type;
0271
0272
0273
0274
0275 template<typename Sequence>
0276 void operator()(Sequence &seq) const
0277 {
0278 seq.pop_back();
0279 }
0280 };
0281
0282
0283 struct pop_front
0284 {
0285 BOOST_PROTO_CALLABLE()
0286 typedef void result_type;
0287
0288
0289
0290
0291 template<typename Sequence>
0292 void operator()(Sequence &seq) const
0293 {
0294 seq.pop_front();
0295 }
0296 };
0297
0298
0299 struct front
0300 {
0301 BOOST_PROTO_CALLABLE()
0302 template<typename Sig>
0303 struct result {};
0304
0305 template<typename This, typename Sequence>
0306 struct result<This(Sequence)>
0307 {
0308 typedef typename remove_reference<Sequence>::type sequence_type;
0309 typedef
0310 typename mpl::if_c<
0311 is_const<sequence_type>::value
0312 , typename sequence_type::const_reference
0313 , typename sequence_type::reference
0314 >::type
0315 type;
0316 };
0317
0318
0319
0320 template<typename Sequence>
0321 typename result<front(Sequence &)>::type operator()(Sequence &seq) const
0322 {
0323 return seq.front();
0324 }
0325 };
0326
0327
0328 struct back
0329 {
0330 BOOST_PROTO_CALLABLE()
0331 template<typename Sig>
0332 struct result {};
0333
0334 template<typename This, typename Sequence>
0335 struct result<This(Sequence)>
0336 {
0337 typedef typename remove_reference<Sequence>::type sequence_type;
0338 typedef
0339 typename mpl::if_c<
0340 is_const<sequence_type>::value
0341 , typename sequence_type::const_reference
0342 , typename sequence_type::reference
0343 >::type
0344 type;
0345 };
0346
0347
0348
0349 template<typename Sequence>
0350 typename result<back(Sequence &)>::type operator()(Sequence &seq) const
0351 {
0352 return seq.back();
0353 }
0354 };
0355
0356
0357 struct top
0358 {
0359 BOOST_PROTO_CALLABLE()
0360 template<typename Sig>
0361 struct result {};
0362
0363 template<typename This, typename Sequence>
0364 struct result<This(Sequence)>
0365 {
0366 typedef typename remove_reference<Sequence>::type sequence_type;
0367 typedef
0368 typename mpl::if_c<
0369 is_const<sequence_type>::value
0370 , typename sequence_type::value_type const &
0371 , typename sequence_type::value_type &
0372 >::type
0373 type;
0374 };
0375
0376
0377
0378 template<typename Sequence>
0379 typename result<top(Sequence &)>::type operator()(Sequence &seq) const
0380 {
0381 return seq.top();
0382 }
0383 };
0384
0385
0386 struct first
0387 {
0388 BOOST_PROTO_CALLABLE()
0389 template<typename Sig>
0390 struct result {};
0391
0392 template<typename This, typename Pair>
0393 struct result<This(Pair)>
0394 {
0395 typedef typename remove_reference<Pair>::type::first_type type;
0396 };
0397
0398
0399
0400 template<typename Pair>
0401 typename Pair::first_type operator()(Pair const &p) const
0402 {
0403 return p.first;
0404 }
0405 };
0406
0407
0408 struct second
0409 {
0410 BOOST_PROTO_CALLABLE()
0411 template<typename Sig>
0412 struct result {};
0413
0414 template<typename This, typename Pair>
0415 struct result<This(Pair)>
0416 {
0417 typedef typename remove_reference<Pair>::type::second_type type;
0418 };
0419
0420
0421
0422 template<typename Pair>
0423 typename Pair::second_type operator()(Pair const &p) const
0424 {
0425 return p.second;
0426 }
0427 };
0428
0429
0430
0431 struct matched
0432 {
0433 BOOST_PROTO_CALLABLE()
0434 typedef bool result_type;
0435
0436
0437
0438 template<typename Sub>
0439 bool operator()(Sub const &sub) const
0440 {
0441 return sub.matched;
0442 }
0443 };
0444
0445
0446 struct length
0447 {
0448 BOOST_PROTO_CALLABLE()
0449 template<typename Sig>
0450 struct result {};
0451
0452 template<typename This, typename Sub>
0453 struct result<This(Sub)>
0454 {
0455 typedef typename remove_reference<Sub>::type::difference_type type;
0456 };
0457
0458
0459
0460 template<typename Sub>
0461 typename Sub::difference_type operator()(Sub const &sub) const
0462 {
0463 return sub.length();
0464 }
0465 };
0466
0467
0468
0469 struct str
0470 {
0471 BOOST_PROTO_CALLABLE()
0472 template<typename Sig>
0473 struct result {};
0474
0475 template<typename This, typename Sub>
0476 struct result<This(Sub)>
0477 {
0478 typedef typename remove_reference<Sub>::type::string_type type;
0479 };
0480
0481
0482
0483 template<typename Sub>
0484 typename Sub::string_type operator()(Sub const &sub) const
0485 {
0486 return sub.str();
0487 }
0488 };
0489
0490
0491
0492
0493
0494
0495
0496
0497 struct insert
0498 {
0499 BOOST_PROTO_CALLABLE()
0500
0501
0502
0503 struct detail
0504 {
0505 template<typename Sig, typename EnableIf = void>
0506 struct result_detail
0507 {};
0508
0509
0510 template<typename This, typename Cont, typename Value>
0511 struct result_detail<This(Cont, Value), void>
0512 {
0513 typedef typename remove_reference<Cont>::type cont_type;
0514 typedef typename remove_reference<Value>::type value_type;
0515 static cont_type &scont_;
0516 static value_type &svalue_;
0517 typedef char yes_type;
0518 typedef char (&no_type)[2];
0519 static yes_type check_insert_return(typename cont_type::iterator);
0520 static no_type check_insert_return(std::pair<typename cont_type::iterator, bool>);
0521 BOOST_STATIC_CONSTANT(bool, is_iterator = (sizeof(yes_type) == sizeof(check_insert_return(scont_.insert(svalue_)))));
0522 typedef
0523 typename mpl::if_c<
0524 is_iterator
0525 , typename cont_type::iterator
0526 , std::pair<typename cont_type::iterator, bool>
0527 >::type
0528 type;
0529 };
0530
0531
0532 template<typename This, typename Cont, typename It, typename Value>
0533 struct result_detail<This(Cont, It, Value),
0534 typename disable_if<
0535 mpl::or_<
0536 is_integral<typename remove_cv<typename remove_reference<It>::type>::type>
0537 , is_same<
0538 typename remove_cv<typename remove_reference<It>::type>::type
0539 , typename remove_cv<typename remove_reference<Value>::type>::type
0540 >
0541 >
0542 >::type
0543 >
0544 {
0545 typedef typename remove_reference<Cont>::type::iterator type;
0546 };
0547
0548
0549 template<typename This, typename Cont, typename Size, typename T>
0550 struct result_detail<This(Cont, Size, T),
0551 typename enable_if<
0552 is_integral<typename remove_cv<typename remove_reference<Size>::type>::type>
0553 >::type
0554 >
0555 {
0556 typedef typename remove_reference<Cont>::type &type;
0557 };
0558
0559
0560 template<typename This, typename Cont, typename It>
0561 struct result_detail<This(Cont, It, It), void>
0562 {
0563 typedef void type;
0564 };
0565
0566
0567 template<typename This, typename Cont, typename It, typename Size, typename Value>
0568 struct result_detail<This(Cont, It, Size, Value),
0569 typename disable_if<
0570 is_integral<typename remove_cv<typename remove_reference<It>::type>::type>
0571 >::type
0572 >
0573 {
0574 typedef void type;
0575 };
0576
0577
0578 template<typename This, typename Cont, typename Size, typename A0, typename A1>
0579 struct result_detail<This(Cont, Size, A0, A1),
0580 typename enable_if<
0581 is_integral<typename remove_cv<typename remove_reference<Size>::type>::type>
0582 >::type
0583 >
0584 {
0585 typedef typename remove_reference<Cont>::type &type;
0586 };
0587
0588
0589 template<typename This, typename Cont, typename Pos0, typename String, typename Pos1, typename Length>
0590 struct result_detail<This(Cont, Pos0, String, Pos1, Length)>
0591 {
0592 typedef typename remove_reference<Cont>::type &type;
0593 };
0594 };
0595
0596 template<typename Sig>
0597 struct result
0598 {
0599 typedef typename detail::result_detail<Sig>::type type;
0600 };
0601
0602
0603
0604 template<typename Cont, typename A0>
0605 typename result<insert(Cont &, A0 const &)>::type
0606 operator()(Cont &cont, A0 const &a0) const
0607 {
0608 return cont.insert(a0);
0609 }
0610
0611
0612
0613 template<typename Cont, typename A0, typename A1>
0614 typename result<insert(Cont &, A0 const &, A1 const &)>::type
0615 operator()(Cont &cont, A0 const &a0, A1 const &a1) const
0616 {
0617 return cont.insert(a0, a1);
0618 }
0619
0620
0621
0622 template<typename Cont, typename A0, typename A1, typename A2>
0623 typename result<insert(Cont &, A0 const &, A1 const &, A2 const &)>::type
0624 operator()(Cont &cont, A0 const &a0, A1 const &a1, A2 const &a2) const
0625 {
0626 return cont.insert(a0, a1, a2);
0627 }
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638 template<typename Cont, typename A0, typename A1, typename A2, typename A3>
0639 typename result<insert(Cont &, A0 const &, A1 const &, A2 const &, A3 const &)>::type
0640 operator()(Cont &cont, A0 const &a0, A1 const &a1, A2 const &a2, A3 const &a3) const
0641 {
0642 return cont.insert(a0, a1, a2, a3);
0643 }
0644 };
0645
0646
0647 struct make_pair
0648 {
0649 BOOST_PROTO_CALLABLE()
0650 template<typename Sig>
0651 struct result {};
0652
0653 template<typename This, typename First, typename Second>
0654 struct result<This(First, Second)>
0655 {
0656
0657 typedef typename decay<First>::type first_type;
0658
0659 typedef typename decay<Second>::type second_type;
0660 typedef std::pair<first_type, second_type> type;
0661 };
0662
0663
0664
0665
0666 template<typename First, typename Second>
0667 std::pair<First, Second> operator()(First const &first, Second const &second) const
0668 {
0669 return std::make_pair(first, second);
0670 }
0671 };
0672
0673
0674
0675 template<typename T>
0676 struct as
0677 {
0678 BOOST_PROTO_CALLABLE()
0679 typedef T result_type;
0680
0681
0682
0683 template<typename Value>
0684 T operator()(Value const &val) const
0685 {
0686 return boost::lexical_cast<T>(val);
0687 }
0688
0689
0690
0691 T operator()(csub_match const &val) const
0692 {
0693 return val.matched
0694 ? boost::lexical_cast<T>(boost::make_iterator_range(val.first, val.second))
0695 : boost::lexical_cast<T>("");
0696 }
0697
0698 #ifndef BOOST_XPRESSIVE_NO_WREGEX
0699
0700 T operator()(wcsub_match const &val) const
0701 {
0702 return val.matched
0703 ? boost::lexical_cast<T>(boost::make_iterator_range(val.first, val.second))
0704 : boost::lexical_cast<T>("");
0705 }
0706 #endif
0707
0708
0709 template<typename BidiIter>
0710 T operator()(sub_match<BidiIter> const &val) const
0711 {
0712
0713
0714 typedef typename iterator_value<BidiIter>::type char_type;
0715 BOOST_MPL_ASSERT_MSG(
0716 (xpressive::detail::is_char<char_type>::value)
0717 , CAN_ONLY_CONVERT_FROM_CHARACTER_SEQUENCES
0718 , (char_type)
0719 );
0720 return this->impl(val, xpressive::detail::is_string_iterator<BidiIter>());
0721 }
0722
0723 private:
0724
0725 template<typename RandIter>
0726 T impl(sub_match<RandIter> const &val, mpl::true_) const
0727 {
0728 return val.matched
0729 ? boost::lexical_cast<T>(boost::make_iterator_range(&*val.first, &*val.first + (val.second - val.first)))
0730 : boost::lexical_cast<T>("");
0731 }
0732
0733
0734 template<typename BidiIter>
0735 T impl(sub_match<BidiIter> const &val, mpl::false_) const
0736 {
0737 return boost::lexical_cast<T>(val.str());
0738 }
0739 };
0740
0741
0742
0743 template<typename T>
0744 struct static_cast_
0745 {
0746 BOOST_PROTO_CALLABLE()
0747 typedef T result_type;
0748
0749
0750
0751 template<typename Value>
0752 T operator()(Value const &val) const
0753 {
0754 return static_cast<T>(val);
0755 }
0756 };
0757
0758
0759
0760 template<typename T>
0761 struct dynamic_cast_
0762 {
0763 BOOST_PROTO_CALLABLE()
0764 typedef T result_type;
0765
0766
0767
0768 template<typename Value>
0769 T operator()(Value const &val) const
0770 {
0771 return dynamic_cast<T>(val);
0772 }
0773 };
0774
0775
0776
0777 template<typename T>
0778 struct const_cast_
0779 {
0780 BOOST_PROTO_CALLABLE()
0781 typedef T result_type;
0782
0783
0784
0785
0786 template<typename Value>
0787 T operator()(Value const &val) const
0788 {
0789 return const_cast<T>(val);
0790 }
0791 };
0792
0793
0794
0795 template<typename T>
0796 struct construct
0797 {
0798 BOOST_PROTO_CALLABLE()
0799 typedef T result_type;
0800
0801
0802 T operator()() const
0803 {
0804 return T();
0805 }
0806
0807
0808 template<typename A0>
0809 T operator()(A0 const &a0) const
0810 {
0811 return T(a0);
0812 }
0813
0814
0815 template<typename A0, typename A1>
0816 T operator()(A0 const &a0, A1 const &a1) const
0817 {
0818 return T(a0, a1);
0819 }
0820
0821
0822
0823
0824
0825 template<typename A0, typename A1, typename A2>
0826 T operator()(A0 const &a0, A1 const &a1, A2 const &a2) const
0827 {
0828 return T(a0, a1, a2);
0829 }
0830 };
0831
0832
0833
0834 template<typename Except>
0835 struct throw_
0836 {
0837 BOOST_PROTO_CALLABLE()
0838 typedef void result_type;
0839
0840
0841 void operator()() const
0842 {
0843 BOOST_THROW_EXCEPTION(Except());
0844 }
0845
0846
0847 template<typename A0>
0848 void operator()(A0 const &a0) const
0849 {
0850 BOOST_THROW_EXCEPTION(Except(a0));
0851 }
0852
0853
0854 template<typename A0, typename A1>
0855 void operator()(A0 const &a0, A1 const &a1) const
0856 {
0857 BOOST_THROW_EXCEPTION(Except(a0, a1));
0858 }
0859
0860
0861
0862
0863
0864
0865
0866
0867 template<typename A0, typename A1, typename A2>
0868 void operator()(A0 const &a0, A1 const &a1, A2 const &a2) const
0869 {
0870 BOOST_THROW_EXCEPTION(Except(a0, a1, a2));
0871 }
0872 };
0873
0874
0875 struct unwrap_reference
0876 {
0877 BOOST_PROTO_CALLABLE()
0878 template<typename Sig>
0879 struct result {};
0880
0881 template<typename This, typename Ref>
0882 struct result<This(Ref)>
0883 {
0884 typedef typename boost::unwrap_reference<Ref>::type &type;
0885 };
0886
0887 template<typename This, typename Ref>
0888 struct result<This(Ref &)>
0889 {
0890 typedef typename boost::unwrap_reference<Ref>::type &type;
0891 };
0892
0893
0894
0895 template<typename T>
0896 T &operator()(boost::reference_wrapper<T> r) const
0897 {
0898 return static_cast<T &>(r);
0899 }
0900 };
0901 }
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930 template<typename PolymorphicFunctionObject>
0931 struct function
0932 {
0933 typedef typename proto::terminal<PolymorphicFunctionObject>::type type;
0934 };
0935
0936
0937
0938 function<op::at>::type const at = {{}};
0939
0940
0941
0942 function<op::push>::type const push = {{}};
0943
0944
0945
0946 function<op::push_back>::type const push_back = {{}};
0947
0948
0949
0950 function<op::push_front>::type const push_front = {{}};
0951
0952
0953
0954 function<op::pop>::type const pop = {{}};
0955
0956
0957
0958 function<op::pop_back>::type const pop_back = {{}};
0959
0960
0961
0962 function<op::pop_front>::type const pop_front = {{}};
0963
0964
0965
0966 function<op::top>::type const top = {{}};
0967
0968
0969
0970 function<op::back>::type const back = {{}};
0971
0972
0973
0974 function<op::front>::type const front = {{}};
0975
0976
0977
0978 function<op::first>::type const first = {{}};
0979
0980
0981
0982 function<op::second>::type const second = {{}};
0983
0984
0985
0986 function<op::matched>::type const matched = {{}};
0987
0988
0989
0990 function<op::length>::type const length = {{}};
0991
0992
0993
0994 function<op::str>::type const str = {{}};
0995
0996
0997
0998 function<op::insert>::type const insert = {{}};
0999
1000
1001
1002 function<op::make_pair>::type const make_pair = {{}};
1003
1004
1005
1006 function<op::unwrap_reference>::type const unwrap_reference = {{}};
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028 template<typename T>
1029 struct value
1030 : proto::extends<typename proto::terminal<T>::type, value<T> >
1031 {
1032
1033 typedef proto::extends<typename proto::terminal<T>::type, value<T> > base_type;
1034
1035
1036 value()
1037 : base_type()
1038 {}
1039
1040
1041
1042 explicit value(T const &t)
1043 : base_type(base_type::proto_base_expr::make(t))
1044 {}
1045
1046 using base_type::operator=;
1047
1048
1049 T &get()
1050 {
1051 return proto::value(*this);
1052 }
1053
1054
1055 T const &get() const
1056 {
1057 return proto::value(*this);
1058 }
1059 };
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080 template<typename T>
1081 struct reference
1082 : proto::extends<typename proto::terminal<reference_wrapper<T> >::type, reference<T> >
1083 {
1084
1085 typedef proto::extends<typename proto::terminal<reference_wrapper<T> >::type, reference<T> > base_type;
1086
1087
1088
1089 explicit reference(T &t)
1090 : base_type(base_type::proto_base_expr::make(boost::ref(t)))
1091 {}
1092
1093 using base_type::operator=;
1094
1095
1096 T &get() const
1097 {
1098 return proto::value(*this).get();
1099 }
1100 };
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126 template<typename T>
1127 struct local
1128 : detail::value_wrapper<T>
1129 , proto::terminal<reference_wrapper<T> >::type
1130 {
1131
1132 typedef typename proto::terminal<reference_wrapper<T> >::type base_type;
1133
1134
1135 local()
1136 : detail::value_wrapper<T>()
1137 , base_type(base_type::make(boost::ref(detail::value_wrapper<T>::value)))
1138 {}
1139
1140
1141
1142 explicit local(T const &t)
1143 : detail::value_wrapper<T>(t)
1144 , base_type(base_type::make(boost::ref(detail::value_wrapper<T>::value)))
1145 {}
1146
1147 using base_type::operator=;
1148
1149
1150 T &get()
1151 {
1152 return proto::value(*this);
1153 }
1154
1155
1156 T const &get() const
1157 {
1158 return proto::value(*this);
1159 }
1160 };
1161
1162
1163
1164
1165
1166 template<typename T, typename A>
1167 typename detail::make_function::impl<op::as<T> const, A const &>::result_type const
1168 as(A const &a)
1169 {
1170 return detail::make_function::impl<op::as<T> const, A const &>()((op::as<T>()), a);
1171 }
1172
1173
1174
1175
1176
1177 template<typename T, typename A>
1178 typename detail::make_function::impl<op::static_cast_<T> const, A const &>::result_type const
1179 static_cast_(A const &a)
1180 {
1181 return detail::make_function::impl<op::static_cast_<T> const, A const &>()((op::static_cast_<T>()), a);
1182 }
1183
1184
1185
1186
1187
1188 template<typename T, typename A>
1189 typename detail::make_function::impl<op::dynamic_cast_<T> const, A const &>::result_type const
1190 dynamic_cast_(A const &a)
1191 {
1192 return detail::make_function::impl<op::dynamic_cast_<T> const, A const &>()((op::dynamic_cast_<T>()), a);
1193 }
1194
1195
1196
1197
1198
1199 template<typename T, typename A>
1200 typename detail::make_function::impl<op::const_cast_<T> const, A const &>::result_type const
1201 const_cast_(A const &a)
1202 {
1203 return detail::make_function::impl<op::const_cast_<T> const, A const &>()((op::const_cast_<T>()), a);
1204 }
1205
1206
1207
1208 template<typename T>
1209 value<T> const val(T const &t)
1210 {
1211 return value<T>(t);
1212 }
1213
1214
1215
1216 template<typename T>
1217 reference<T> const ref(T &t)
1218 {
1219 return reference<T>(t);
1220 }
1221
1222
1223
1224
1225 template<typename T>
1226 reference<T const> const cref(T const &t)
1227 {
1228 return reference<T const>(t);
1229 }
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
1286 template<typename T>
1287 detail::unspecified check(T const &t);
1288 #else
1289 proto::terminal<detail::check_tag>::type const check = {{}};
1290 #endif
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
1352 template<typename...ArgBindings>
1353 detail::unspecified let(ArgBindings const &...args);
1354 #else
1355 detail::let_<proto::terminal<detail::let_tag>::type> const let = {{{}}};
1356 #endif
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
1446 template<typename T, int I = 0>
1447 struct placeholder
1448 {
1449
1450
1451
1452 detail::unspecified operator=(T &t) const;
1453
1454 detail::unspecified operator=(T const &t) const;
1455 };
1456 #else
1457 template<typename T, int I, typename Dummy>
1458 struct placeholder
1459 {
1460 typedef placeholder<T, I, Dummy> this_type;
1461 typedef
1462 typename proto::terminal<detail::action_arg<T, mpl::int_<I> > >::type
1463 action_arg_type;
1464
1465 BOOST_PROTO_EXTENDS(action_arg_type, this_type, proto::default_domain)
1466 };
1467 #endif
1468
1469
1470
1471
1472
1473
1474
1475 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
1476 template<typename T, typename ...Args>
1477 detail::unspecified construct(Args const &...args);
1478 #else
1479
1480 #define BOOST_PROTO_LOCAL_MACRO(N, typename_A, A_const_ref, A_const_ref_a, a) \
1481 template<typename X2_0 BOOST_PP_COMMA_IF(N) typename_A(N)> \
1482 typename detail::make_function::impl< \
1483 op::construct<X2_0> const \
1484 BOOST_PP_COMMA_IF(N) A_const_ref(N) \
1485 >::result_type const \
1486 construct(A_const_ref_a(N)) \
1487 { \
1488 return detail::make_function::impl< \
1489 op::construct<X2_0> const \
1490 BOOST_PP_COMMA_IF(N) A_const_ref(N) \
1491 >()((op::construct<X2_0>()) BOOST_PP_COMMA_IF(N) a(N)); \
1492 } \
1493 \
1494 template<typename X2_0 BOOST_PP_COMMA_IF(N) typename_A(N)> \
1495 typename detail::make_function::impl< \
1496 op::throw_<X2_0> const \
1497 BOOST_PP_COMMA_IF(N) A_const_ref(N) \
1498 >::result_type const \
1499 throw_(A_const_ref_a(N)) \
1500 { \
1501 return detail::make_function::impl< \
1502 op::throw_<X2_0> const \
1503 BOOST_PP_COMMA_IF(N) A_const_ref(N) \
1504 >()((op::throw_<X2_0>()) BOOST_PP_COMMA_IF(N) a(N)); \
1505 } \
1506
1507
1508 #define BOOST_PROTO_LOCAL_a BOOST_PROTO_a
1509 #define BOOST_PROTO_LOCAL_LIMITS (0, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
1510 #include BOOST_PROTO_LOCAL_ITERATE()
1511 #endif
1512
1513 namespace detail
1514 {
1515 inline void ignore_unused_regex_actions()
1516 {
1517 detail::ignore_unused(xpressive::at);
1518 detail::ignore_unused(xpressive::push);
1519 detail::ignore_unused(xpressive::push_back);
1520 detail::ignore_unused(xpressive::push_front);
1521 detail::ignore_unused(xpressive::pop);
1522 detail::ignore_unused(xpressive::pop_back);
1523 detail::ignore_unused(xpressive::pop_front);
1524 detail::ignore_unused(xpressive::top);
1525 detail::ignore_unused(xpressive::back);
1526 detail::ignore_unused(xpressive::front);
1527 detail::ignore_unused(xpressive::first);
1528 detail::ignore_unused(xpressive::second);
1529 detail::ignore_unused(xpressive::matched);
1530 detail::ignore_unused(xpressive::length);
1531 detail::ignore_unused(xpressive::str);
1532 detail::ignore_unused(xpressive::insert);
1533 detail::ignore_unused(xpressive::make_pair);
1534 detail::ignore_unused(xpressive::unwrap_reference);
1535 detail::ignore_unused(xpressive::check);
1536 detail::ignore_unused(xpressive::let);
1537 }
1538
1539 struct mark_nbr
1540 {
1541 BOOST_PROTO_CALLABLE()
1542 typedef int result_type;
1543
1544 int operator()(mark_placeholder m) const
1545 {
1546 return m.mark_number_;
1547 }
1548 };
1549
1550 struct ReplaceAlgo
1551 : proto::or_<
1552 proto::when<
1553 proto::terminal<mark_placeholder>
1554 , op::at(proto::_data, proto::call<mark_nbr(proto::_value)>)
1555 >
1556 , proto::when<
1557 proto::terminal<any_matcher>
1558 , op::at(proto::_data, proto::size_t<0>)
1559 >
1560 , proto::when<
1561 proto::terminal<reference_wrapper<proto::_> >
1562 , op::unwrap_reference(proto::_value)
1563 >
1564 , proto::_default<ReplaceAlgo>
1565 >
1566 {};
1567 }
1568 }}
1569
1570 #if BOOST_MSVC
1571 #pragma warning(pop)
1572 #endif
1573
1574 #endif