Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file is_noncopyable.hpp
0003 /// Utility for detecting when types are non-copyable
0004 //
0005 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_PROTO_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012
0010 #define BOOST_PROTO_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012
0011 
0012 #include <boost/noncopyable.hpp>
0013 #include <boost/mpl/or.hpp>
0014 #include <boost/mpl/bool.hpp>
0015 #include <boost/type_traits/is_base_of.hpp>
0016 #include <boost/type_traits/is_abstract.hpp>
0017 #include <boost/type_traits/is_function.hpp>
0018 #include <boost/proto/proto_fwd.hpp>
0019 
0020 namespace boost { namespace proto { namespace detail
0021 {
0022     // All classes derived from std::ios_base have these public nested types,
0023     // and are non-copyable. This is an imperfect test, but it's the best we
0024     // we can do.
0025     template<typename T>
0026     yes_type check_is_iostream(
0027         typename T::failure *
0028       , typename T::Init *
0029       , typename T::fmtflags *
0030       , typename T::iostate *
0031       , typename T::openmode *
0032       , typename T::seekdir *
0033     );
0034 
0035     template<typename T>
0036     no_type check_is_iostream(...);
0037 
0038     template<typename T>
0039     struct is_iostream
0040     {
0041         static bool const value = sizeof(yes_type) == sizeof(check_is_iostream<T>(0,0,0,0,0,0));
0042         typedef mpl::bool_<value> type;
0043     };
0044 
0045     /// INTERNAL ONLY
0046     // This should be a customization point. And it serves the same purpose
0047     // as the is_noncopyable trait in Boost.Foreach. 
0048     template<typename T>
0049     struct is_noncopyable
0050         : mpl::or_<
0051             is_function<T>
0052           , is_abstract<T>
0053           , is_iostream<T>
0054           , is_base_of<noncopyable, T>
0055         >
0056     {};
0057 
0058     template<typename T, std::size_t N>
0059     struct is_noncopyable<T[N]>
0060       : mpl::true_
0061     {};
0062 
0063 }}}
0064 
0065 #endif