]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/optional/test/optional_test_constructible_from_other.cpp
1 // Copyright (c) 2018 Andrey Semashev
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // The test verifies that Boost.Optional copy constructors do not attempt to invoke
8 // the element type initializing constructors from templated arguments
10 #include <boost/optional/optional.hpp>
11 #include <boost/core/enable_if.hpp>
23 template< unsigned int Size
>
26 template< typename T
, typename U
>
27 struct is_constructible
29 template< typename T1
, typename U1
>
30 static yes_type
check_helper(size_tag
< sizeof(static_cast< T1
>(U1())) >*);
31 template< typename T1
, typename U1
>
32 static no_type
check_helper(...);
34 static const bool value
= sizeof(check_helper
< T
, U
>(0)) == sizeof(yes_type
);
37 template< typename T
>
42 wrapper(wrapper
const&) {}
43 template< typename U
>
44 wrapper(U
const&, typename
boost::enable_if_c
< is_constructible
< T
, U
>::value
, int >::type
= 0) {}
47 inline boost::optional
< wrapper
< int > > foo()
49 return boost::optional
< wrapper
< int > >();
54 // Invokes boost::optional copy constructor. Should not invoke wrapper constructor from U.
55 boost::optional
< wrapper
< int > > res
= foo();