// Boost.TypeErasure library // // Copyright 2012 Steven Watanabe // // Distributed under the Boost Software License Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // $Id$ #ifndef BOOST_TYPE_ERASURE_DETAIL_CONST_HPP_INCLUDED #define BOOST_TYPE_ERASURE_DETAIL_CONST_HPP_INCLUDED #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace type_erasure { namespace detail { template struct is_non_const_ref : boost::mpl::false_ {}; template struct is_non_const_ref : boost::mpl::true_ {}; template struct is_non_const_ref : boost::mpl::false_ {}; template struct should_be_const : ::boost::mpl::or_< ::boost::is_const, ::boost::type_erasure::detail::is_non_const_ref< typename ::boost::type_erasure::placeholder_of::type > > {}; template struct should_be_non_const : ::boost::mpl::and_< ::boost::mpl::not_< ::boost::is_const >, ::boost::mpl::not_< ::boost::is_reference< typename ::boost::type_erasure::placeholder_of::type > > > {}; template struct non_const_this_param { typedef typename ::boost::type_erasure::placeholder_of::type placeholder; typedef typename ::boost::type_erasure::derived::type plain_type; typedef typename ::boost::mpl::if_< ::boost::is_same< placeholder, typename ::boost::remove_cv< typename ::boost::remove_reference::type >::type& >, const plain_type, plain_type >::type type; }; template struct uncallable {}; template struct maybe_const_this_param { typedef typename ::boost::type_erasure::derived::type plain_type; typedef typename ::boost::remove_reference::type plain_placeholder; typedef typename ::boost::mpl::if_< ::boost::is_reference, typename ::boost::mpl::if_< ::boost::type_erasure::detail::should_be_non_const, plain_type&, typename ::boost::mpl::if_< ::boost::type_erasure::detail::should_be_const, const plain_type&, uncallable >::type >::type, plain_type >::type type; }; #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template struct maybe_const_this_param { typedef typename ::boost::type_erasure::derived::type plain_type; typedef typename ::boost::remove_reference::type plain_placeholder; typedef typename ::boost::type_erasure::placeholder_of::type self_placeholder; typedef typename ::boost::mpl::if_< ::boost::is_lvalue_reference, ::boost::type_erasure::detail::uncallable, typename ::boost::mpl::if_< ::boost::is_rvalue_reference, const plain_type&, plain_type&& >::type >::type type; }; #endif } } } #endif