• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.TypeErasure library
2 //
3 // Copyright 2011 Steven Watanabe
4 //
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // $Id$
10 
11 #include <boost/type_erasure/any.hpp>
12 #include <boost/type_erasure/builtin.hpp>
13 #include <boost/type_traits/is_constructible.hpp>
14 #include <boost/type_traits/is_copy_constructible.hpp>
15 #include <boost/mpl/vector.hpp>
16 #include <boost/mpl/assert.hpp>
17 
18 using namespace boost::type_erasure;
19 
20 #if defined(BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS)
21 
22 using boost::is_copy_constructible;
23 
24 template<class T>
25 using is_move_constructible = boost::is_constructible<T, T&&>;
26 
27 template<class T>
28 using is_mutable_constructible = boost::is_constructible<T, T&>;
29 
30 using move_constructible = boost::mpl::vector<constructible<_self(_self&&)>, destructible<> >;
31 using mutable_copy = boost::mpl::vector<constructible<_self(_self&)>, destructible<> >;
32 
33 BOOST_MPL_ASSERT_NOT((is_copy_constructible<any<destructible<> > >));
34 BOOST_MPL_ASSERT((is_copy_constructible<any<copy_constructible<> > >));
35 BOOST_MPL_ASSERT_NOT((is_copy_constructible<any<move_constructible> >));
36 
37 // only is_copy_constructible seems to work on msvc and
38 // even that breaks when we add a non-const copy constructor.
39 #if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1912)) && \
40     !BOOST_WORKAROUND(BOOST_GCC, < 70000) && \
41     !BOOST_WORKAROUND(__clang__major__, < 4)
42 
43 BOOST_MPL_ASSERT_NOT((is_mutable_constructible<any<destructible<> > >));
44 BOOST_MPL_ASSERT_NOT((is_move_constructible<any<destructible<> > >));
45 
46 BOOST_MPL_ASSERT((is_mutable_constructible<any<copy_constructible<> > >));
47 BOOST_MPL_ASSERT((is_move_constructible<any<copy_constructible<> > >));
48 
49 BOOST_MPL_ASSERT_NOT((is_mutable_constructible<any<move_constructible> >));
50 BOOST_MPL_ASSERT((is_move_constructible<any<move_constructible> >));
51 
52 BOOST_MPL_ASSERT((is_mutable_constructible<any<mutable_copy> >));
53 BOOST_MPL_ASSERT_NOT((is_copy_constructible<any<mutable_copy> >));
54 BOOST_MPL_ASSERT_NOT((is_move_constructible<any<mutable_copy> >));
55 
56 #endif
57 
58 #endif
59