Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:34

0001 // (C) Copyright Thorsten Ottosen 2005
0002 // (C) Copyright Howard Hinnant 2004
0003 // (C) Copyright Jonathan Turkanis 2004
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0006 
0007 //
0008 // Contains type traits machinery for incomplete arrays. MPL compatibility
0009 // is included for completeness, but is not necessary for the current
0010 // application.
0011 //
0012 
0013 #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
0014 #define BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
0015 
0016 #include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
0017 #include <boost/mpl/aux_/lambda_support.hpp>
0018 #include <boost/mpl/and.hpp>
0019 #include <boost/mpl/bool.hpp>
0020 #include <boost/mpl/identity.hpp>
0021 #include <boost/mpl/if.hpp>
0022 #include <boost/type_traits/is_array.hpp>
0023 #include <boost/type_traits/is_convertible.hpp>
0024 #include <boost/type_traits/is_same.hpp>
0025 #include <boost/type_traits/remove_bounds.hpp>
0026 #include <boost/type_traits/remove_cv.hpp>
0027 #include <boost/utility/enable_if.hpp>
0028 
0029 namespace boost { namespace ptr_container_detail { namespace move_ptrs {
0030 
0031 // From Howard Hinnant.
0032 template<typename T, typename U>
0033 struct is_array_convertible {
0034     typedef typename remove_bounds<T>::type      t_element;
0035     typedef typename remove_bounds<U>::type      u_element;
0036     typedef typename remove_cv<t_element>::type  t_base;
0037     typedef typename remove_cv<u_element>::type  u_base;
0038     typedef typename
0039             mpl::and_<
0040                 is_array<T>,
0041                 is_array<U>,
0042                 is_same<t_base, u_base>,
0043                 is_convertible<t_element*, u_element*>
0044             >::type                                     type;
0045     BOOST_STATIC_CONSTANT(bool, value = type::value);
0046     BOOST_MPL_AUX_LAMBDA_SUPPORT(2, is_array_convertible, (T, U))
0047 };
0048 
0049 template<typename T, typename U>
0050 struct is_smart_ptr_convertible
0051     : mpl::if_<
0052           is_array<T>,
0053           is_array_convertible<T, U>,
0054           is_convertible<T*, U*>
0055       >::type
0056     { };
0057 
0058 #ifndef BOOST_NO_SFINAE
0059     template<typename Src, typename Tgt, typename T = void>
0060     struct enable_if_convertible
0061         : enable_if<
0062               is_smart_ptr_convertible<Src, Tgt>,
0063               T
0064           >
0065         { };
0066 #else
0067     template<typename Src, typename Tgt, class T >
0068     struct enable_if_convertible : mpl::identity<T> { };
0069 #endif
0070 
0071 } } }         // End namespaces ptr_container_detail, move_ptrs, boost.
0072 
0073 #endif      // #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED