Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/type_erasure/builtin.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Boost.TypeErasure library
0002 //
0003 // Copyright 2011 Steven Watanabe
0004 //
0005 // Distributed under the Boost Software License Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // $Id$
0010 
0011 #ifndef BOOST_TYPE_ERASURE_BUILTIN_HPP_INCLUDED
0012 #define BOOST_TYPE_ERASURE_BUILTIN_HPP_INCLUDED
0013 
0014 #include <boost/mpl/vector.hpp>
0015 #include <boost/utility/enable_if.hpp>
0016 #include <boost/type_traits/is_reference.hpp>
0017 #include <boost/type_erasure/detail/storage.hpp>
0018 #include <boost/type_erasure/placeholder.hpp>
0019 #include <boost/type_erasure/constructible.hpp>
0020 #include <boost/type_erasure/rebind_any.hpp>
0021 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0022 #   include <utility>  // std::move
0023 #endif
0024 #include <typeinfo>
0025 
0026 namespace boost {
0027 namespace type_erasure {
0028 
0029 /**
0030  * The @ref destructible concept enables forwarding to
0031  * the destructor of the contained type.  This is required
0032  * whenever an @ref any is created by value.
0033  *
0034  * \note The @ref destructible concept rarely needs to
0035  * be specified explicitly, because it is included in
0036  * the @ref copy_constructible concept.
0037  *
0038  * \note @ref destructible may not be specialized and
0039  * may not be passed to \call as it depends on the
0040  * implementation details of @ref any.
0041  */
0042 template<class T = _self>
0043 struct destructible
0044 {
0045     /** INTERNAL ONLY */
0046     typedef void (*type)(detail::storage&);
0047     /** INTERNAL ONLY */
0048     static void value(detail::storage& arg)
0049     {
0050         delete static_cast<T*>(arg.data);
0051     }
0052     /** INTERNAL ONLY */
0053     static void apply(detail::storage& arg)
0054     { 
0055         delete static_cast<T*>(arg.data);
0056     }
0057 };
0058 
0059 /**
0060  * The @ref copy_constructible concept allows objects to
0061  * be copied and destroyed.
0062  *
0063  * \note This concept is defined to match C++ 2003,
0064  * [lib.copyconstructible].  It is not equivalent to
0065  * the concept of the same name in C++11.
0066  */
0067 template<class T = _self>
0068 struct copy_constructible :
0069     ::boost::mpl::vector<constructible<T(const T&)>, destructible<T> >
0070 {};
0071 
0072 #ifdef BOOST_TYPE_ERASURE_DOXYGEN
0073 
0074 /**
0075  * Enables assignment of @ref any types.
0076  */
0077 template<class T = _self, class U = const T&>
0078 struct assignable
0079 {
0080     static void apply(T& dst, U src);
0081 };
0082 
0083 #else
0084 
0085 /**
0086  * Enables assignment of @ref any types.
0087  */
0088 template<class T = _self, class U = const T&>
0089 struct assignable :
0090     ::boost::mpl::vector<assignable<T, const U&> >
0091 {};
0092 
0093 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0094 
0095 /** INTERNAL ONLY */
0096 template<class T, class U>
0097 struct assignable<T, U&&>
0098 {
0099     static void apply(T& dst, U&& src) { dst = std::forward<U>(src); }
0100 };
0101 
0102 #endif
0103 
0104 /** INTERNAL ONLY */
0105 template<class T, class U>
0106 struct assignable<T, U&>
0107 {
0108     static void apply(T& dst, U& src) { dst = src; }
0109 };
0110 
0111 /** INTERNAL ONLY */
0112 template<class T, class U, class Base>
0113 struct concept_interface<assignable<T, U>, Base, T,
0114         typename ::boost::enable_if_c< ::boost::is_reference<U>::value>::type> : Base
0115 {
0116     using Base::_boost_type_erasure_deduce_assign;
0117     assignable<T, U>* _boost_type_erasure_deduce_assign(
0118         typename ::boost::type_erasure::as_param<Base, U>::type)
0119     {
0120         return 0;
0121     }
0122 };
0123 
0124 #endif
0125 
0126 /**
0127  * Enables runtime type information.  This is required
0128  * if you want to use \any_cast or \typeid_of.
0129  *
0130  * \note @ref typeid_ cannot be specialized because several
0131  * library components including \any_cast would not work
0132  * correctly if its behavior changed.  There is no need
0133  * to specialize it anyway, since it works for all types.
0134  * @ref typeid_ also cannot be passed to \call.  To access it,
0135  * use \typeid_of.
0136  */
0137 template<class T = _self>
0138 struct typeid_
0139 {
0140     /** INTERNAL ONLY */
0141     typedef const std::type_info& (*type)();
0142     /** INTERNAL ONLY */
0143     static const std::type_info& value()
0144     {
0145         return typeid(T);
0146     }
0147     /** INTERNAL ONLY */
0148     static const std::type_info& apply()
0149     {
0150         return typeid(T);
0151     }
0152 };
0153 
0154 namespace detail {
0155 
0156 template<class C>
0157 struct get_null_vtable_entry;
0158 
0159 template<class T>
0160 struct get_null_vtable_entry< ::boost::type_erasure::typeid_<T> >
0161 {
0162     typedef typeid_<void> type;
0163 };
0164 
0165 struct null_destroy {
0166     static void value(::boost::type_erasure::detail::storage&) {}
0167 };
0168 
0169 template<class T>
0170 struct get_null_vtable_entry< ::boost::type_erasure::destructible<T> >
0171 {
0172     typedef ::boost::type_erasure::detail::null_destroy type;
0173 };
0174 
0175 }
0176 
0177 }
0178 }
0179 
0180 #endif