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
18using namespace boost::type_erasure;
19
20#if defined(BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS)
21
22using boost::is_copy_constructible;
23
24template<class T>
25using is_move_constructible = boost::is_constructible<T, T&&>;
26
27template<class T>
28using is_mutable_constructible = boost::is_constructible<T, T&>;
29
30using move_constructible = boost::mpl::vector<constructible<_self(_self&&)>, destructible<> >;
31using mutable_copy = boost::mpl::vector<constructible<_self(_self&)>, destructible<> >;
32
33BOOST_MPL_ASSERT_NOT((is_copy_constructible<any<destructible<> > >));
34BOOST_MPL_ASSERT((is_copy_constructible<any<copy_constructible<> > >));
35BOOST_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
43BOOST_MPL_ASSERT_NOT((is_mutable_constructible<any<destructible<> > >));
44BOOST_MPL_ASSERT_NOT((is_move_constructible<any<destructible<> > >));
45
46BOOST_MPL_ASSERT((is_mutable_constructible<any<copy_constructible<> > >));
47BOOST_MPL_ASSERT((is_move_constructible<any<copy_constructible<> > >));
48
49BOOST_MPL_ASSERT_NOT((is_mutable_constructible<any<move_constructible> >));
50BOOST_MPL_ASSERT((is_move_constructible<any<move_constructible> >));
51
52BOOST_MPL_ASSERT((is_mutable_constructible<any<mutable_copy> >));
53BOOST_MPL_ASSERT_NOT((is_copy_constructible<any<mutable_copy> >));
54BOOST_MPL_ASSERT_NOT((is_move_constructible<any<mutable_copy> >));
55
56#endif
57
58#endif
59

source code of boost/libs/type_erasure/test/test_sfinae.cpp