diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index e31b167..67b6a92 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -9,7 +9,6 @@ #include #include -#include #include // @@ -29,6 +28,8 @@ namespace boost { +// reference_wrapper + template class reference_wrapper { public: @@ -47,70 +48,100 @@ private: T* t_; }; +// ref + # if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) ) # define BOOST_REF_CONST # else # define BOOST_REF_CONST const # endif -template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref(T & t) +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( T & t ) { return reference_wrapper(t); } -template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST cref(T const & t) +// cref + +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST cref( T const & t ) { return reference_wrapper(t); } # undef BOOST_REF_CONST +// is_reference_wrapper -template -class is_reference_wrapper - : public mpl::false_ +template struct is_reference_wrapper { + BOOST_STATIC_CONSTANT( bool, value = false ); }; -template -class unwrap_reference +template struct is_reference_wrapper< reference_wrapper > +{ + BOOST_STATIC_CONSTANT( bool, value = true ); +}; + +#if !defined(BOOST_NO_CV_SPECIALIZATIONS) + +template struct is_reference_wrapper< reference_wrapper const > +{ + BOOST_STATIC_CONSTANT( bool, value = true ); +}; + +template struct is_reference_wrapper< reference_wrapper volatile > +{ + BOOST_STATIC_CONSTANT( bool, value = true ); +}; + +template struct is_reference_wrapper< reference_wrapper const volatile > +{ + BOOST_STATIC_CONSTANT( bool, value = true ); +}; + +#endif // !defined(BOOST_NO_CV_SPECIALIZATIONS) + +// unwrap_reference + +template struct unwrap_reference { - public: typedef T type; }; -# define AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(X) \ -template \ -class is_reference_wrapper< X > \ - : public mpl::true_ \ -{ \ -}; \ -\ -template \ -class unwrap_reference< X > \ -{ \ - public: \ - typedef T type; \ -}; \ -/**/ +template struct unwrap_reference< reference_wrapper > +{ + typedef T type; +}; -AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper) #if !defined(BOOST_NO_CV_SPECIALIZATIONS) -AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper const) -AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper volatile) -AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper const volatile) -#endif -# undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF +template struct unwrap_reference< reference_wrapper const > +{ + typedef T type; +}; +template struct unwrap_reference< reference_wrapper volatile > +{ + typedef T type; +}; -template BOOST_FORCEINLINE typename unwrap_reference::type& -unwrap_ref(T& t) +template struct unwrap_reference< reference_wrapper const volatile > +{ + typedef T type; +}; + +#endif // !defined(BOOST_NO_CV_SPECIALIZATIONS) + +// unwrap_ref + +template BOOST_FORCEINLINE typename unwrap_reference::type& unwrap_ref( T & t ) { return t; } -template BOOST_FORCEINLINE T* get_pointer( reference_wrapper const & r ) +// get_pointer + +template BOOST_FORCEINLINE T* get_pointer( reference_wrapper const & r ) { return r.get_pointer(); }