Ticket #4542: bind.patch
File bind.patch, 9.0 KB (added by , 12 years ago) |
---|
-
bind.hpp
29 29 #include <boost/bind/arg.hpp> 30 30 #include <boost/detail/workaround.hpp> 31 31 #include <boost/visit_each.hpp> 32 #include <boost/utility/result_of.hpp> 32 33 33 34 // Borland-specific bug, visit_each() silently fails to produce code 34 35 … … 272 273 struct logical_and; 273 274 struct logical_or; 274 275 276 struct invalid{}; 277 278 template<class F,class L,class T,class Args> 279 struct argresult; 280 281 template<class F,class L,class T,class Args> 282 struct argresult<F,L,value<T>,Args>{ 283 typedef T type; 284 }; 285 286 template<class F, class L,int I> 287 struct argresult<F,L,boost::arg<I>,bind_t<unspecified,F,L>()>{ 288 typedef invalid type; 289 }; 290 291 template<class F, class L, class A1> 292 struct argresult<F,L,boost::arg<1>,bind_t<unspecified,F,L>(A1)>{ 293 typedef A1 type; 294 }; 295 296 template<class F, class L, class A1> 297 struct argresult<F,L,boost::arg<1>,bind_t<unspecified,F,L>(A1 &)>{ 298 typedef A1 const &type; 299 }; 300 301 template<class F, class L, class A1,class A2> 302 struct argresult<F,L,boost::arg<1>,bind_t<unspecified,F,L>(A1,A2)>{ 303 typedef A1 type; 304 }; 305 306 template<class F, class L, class A1,class A2> 307 struct argresult<F,L,boost::arg<1>,bind_t<unspecified,F,L>(A1 &,A2)>{ 308 typedef A1 const &type; 309 }; 310 311 template<class F, class A1, class A2> 312 struct fresult2{ 313 typedef typename boost::result_of<F(A1,A2)>::type type; 314 }; 315 316 template<class F,class A1> 317 struct fresult2<F,A1,invalid>{ 318 typedef invalid type; 319 }; 320 321 template<class F,class A2> 322 struct fresult2<F,invalid,A2>{ 323 typedef invalid type; 324 }; 325 326 template<class F> 327 struct fresult2<F,invalid,invalid>{ 328 typedef invalid type; 329 }; 330 275 331 template< class A1, class A2 > class list2: private storage2< A1, A2 > 276 332 { 277 333 private: … … 280 336 281 337 public: 282 338 339 template<class R, class F, class Args> 340 struct bresult{ 341 typedef typename fresult2< 342 F, 343 typename argresult<F,list2,A1,Args>::type, 344 typename argresult<F,list2,A2,Args>::type 345 >::type type; 346 }; 347 283 348 list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {} 284 349 285 350 A1 operator[] (boost::arg<1>) const { return base_type::a1_; } … … 349 414 } 350 415 }; 351 416 417 352 418 template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 > 353 419 { 354 420 private: … … 861 927 862 928 #ifndef BOOST_NO_VOID_RETURNS 863 929 930 template<class R, class F, class L, class Args> 931 struct bind_result; 932 864 933 template<class R, class F, class L> class bind_t 865 934 { 866 935 public: … … 875 944 876 945 }; 877 946 947 878 948 #else 879 949 880 950 template<class R> struct bind_t_generator -
bind_template.hpp
12 12 // See http://www.boost.org/libs/bind/bind.html for documentation. 13 13 // 14 14 15 typedef typename result_traits<R, F>::type result_type; 15 template<typename Args> 16 struct result{ 17 typedef typename L::bresult<R,F,Args>::type type; 18 }; 16 19 17 result_type operator()()20 typename result<this_type()>::type operator()() 18 21 { 19 22 list0 a; 20 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);23 BOOST_BIND_RETURN l_(type<typename result<this_type()>::type>(), f_, a, 0); 21 24 } 22 25 23 result_type operator()() const26 typename result<this_type()>::type operator()() const 24 27 { 25 28 list0 a; 26 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);29 BOOST_BIND_RETURN l_(type<typename result<this_type()>::type>(), f_, a, 0); 27 30 } 28 31 29 template<class A1> result_type operator()(A1 & a1)32 template<class A1> typename result<this_type(A1 &)>::type operator()(A1 & a1) 30 33 { 31 34 list1<A1 &> a(a1); 32 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);35 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &)>::type>(), f_, a, 0); 33 36 } 34 37 35 template<class A1> result_type operator()(A1 & a1) const38 template<class A1> typename result<this_type(A1 &)>::type operator()(A1 & a1) const 36 39 { 37 40 list1<A1 &> a(a1); 38 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);41 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &)>::type>(), f_, a, 0); 39 42 } 40 43 41 44 #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ 42 45 && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) 43 46 44 template<class A1> result_type operator()(A1 const & a1)47 template<class A1> typename result<this_type(A1 const &)>::type operator()(A1 const & a1) 45 48 { 46 49 list1<A1 const &> a(a1); 47 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);50 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &)>::type>(), f_, a, 0); 48 51 } 49 52 50 template<class A1> result_type operator()(A1 const & a1) const53 template<class A1> typename result<this_type(A1 const &)>::type operator()(A1 const & a1) const 51 54 { 52 55 list1<A1 const &> a(a1); 53 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);56 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &)>::type>(), f_, a, 0); 54 57 } 55 58 56 59 #endif 57 60 58 template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)61 template<class A1, class A2> typename result<this_type(A1 &,A2 &)>::type operator()(A1 & a1, A2 & a2) 59 62 { 60 63 list2<A1 &, A2 &> a(a1, a2); 61 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);64 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &,A2 &)>::type>(), f_, a, 0); 62 65 } 63 66 64 template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const67 template<class A1, class A2> typename result<this_type(A1 &,A2 &)>::type operator()(A1 & a1, A2 & a2) const 65 68 { 66 69 list2<A1 &, A2 &> a(a1, a2); 67 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);70 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &,A2 &)>::type>(), f_, a, 0); 68 71 } 69 72 70 73 #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ 71 74 && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) 72 75 73 template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2)76 template<class A1, class A2> typename result<this_type(A1 const &,A2 &)>::type operator()(A1 const & a1, A2 & a2) 74 77 { 75 78 list2<A1 const &, A2 &> a(a1, a2); 76 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);79 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &,A2 &)>::type>(), f_, a, 0); 77 80 } 78 81 79 template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2) const82 template<class A1, class A2> typename result<this_type(A1 const &,A2 &)>::type operator()(A1 const & a1, A2 & a2) const 80 83 { 81 84 list2<A1 const &, A2 &> a(a1, a2); 82 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);85 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &,A2 &)>::type>(), f_, a, 0); 83 86 } 84 87 85 88 86 template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2)89 template<class A1, class A2> typename result<this_type(A1 &,A2 const &)>::type operator()(A1 & a1, A2 const & a2) 87 90 { 88 91 list2<A1 &, A2 const &> a(a1, a2); 89 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);92 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &,A2 const &)>::type>(), f_, a, 0); 90 93 } 91 94 92 template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2) const95 template<class A1, class A2> typename result<this_type(A1 &,A2 const &)>::type operator()(A1 & a1, A2 const & a2) const 93 96 { 94 97 list2<A1 &, A2 const &> a(a1, a2); 95 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);98 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 &,A2 const &)>::type>(), f_, a, 0); 96 99 } 97 100 98 101 99 template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2)102 template<class A1, class A2> typename result<this_type(A1 const &,A2 const &)>::type operator()(A1 const & a1, A2 const & a2) 100 103 { 101 104 list2<A1 const &, A2 const &> a(a1, a2); 102 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);105 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &,A2 const &)>::type>(), f_, a, 0); 103 106 } 104 107 105 template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2) const108 template<class A1, class A2> typename result<this_type(A1 const &,A2 const &)>::type operator()(A1 const & a1, A2 const & a2) const 106 109 { 107 110 list2<A1 const &, A2 const &> a(a1, a2); 108 BOOST_BIND_RETURN l_(type< result_type>(), f_, a, 0);111 BOOST_BIND_RETURN l_(type<typename result<this_type(A1 const &,A2 const &)>::type>(), f_, a, 0); 109 112 } 110 113 111 114 #endif 112 115 #if 0 113 116 template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) 114 117 { 115 118 list3<A1 &, A2 &, A3 &> a(a1, a2, a3); … … 312 315 } 313 316 314 317 #endif 315 318 #endif 319 #if 0 316 320 template<class A> result_type eval(A & a) 317 321 { 318 322 BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0); … … 322 326 { 323 327 BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0); 324 328 } 329 #endif 325 330 326 331 template<class V> void accept(V & v) const 327 332 {