]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // Copyright (C) 2019 Andrzej Krzemienski. |
2 | // | |
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) | |
6 | // | |
7 | // See http://www.boost.org/lib/optional for documentation. | |
8 | // | |
9 | // You are welcome to contact the author at: | |
10 | // akrzemi1@gmail.com | |
11 | ||
12 | #include "boost/optional/optional.hpp" | |
13 | ||
20effc67 | 14 | #ifdef BOOST_BORLANDC |
f67539c2 TL |
15 | #pragma hdrstop |
16 | #endif | |
17 | ||
18 | #ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT | |
19 | #ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS | |
20 | template <typename, typename> | |
21 | struct void_t | |
22 | { | |
23 | typedef void type; | |
24 | }; | |
25 | ||
26 | ||
27 | template <typename T, typename = void> | |
28 | struct trait | |
29 | { | |
30 | }; | |
31 | ||
32 | // the following trait emulates properties std::iterator_traits | |
33 | template <typename T> | |
34 | struct trait<T, BOOST_DEDUCED_TYPENAME void_t<BOOST_DEDUCED_TYPENAME T::value_type, | |
35 | BOOST_DEDUCED_TYPENAME boost::enable_if<boost::is_constructible<T, T&> >::type | |
36 | >::type> | |
37 | { | |
38 | typedef BOOST_DEDUCED_TYPENAME T::value_type value_type; | |
39 | }; | |
40 | ||
41 | // This class emulates the properties of std::filesystem::path | |
42 | struct Path | |
43 | { | |
44 | ||
45 | #if __cplusplus >= 201103 | |
46 | template <typename T, typename = BOOST_DEDUCED_TYPENAME trait<T>::value_type> | |
47 | Path(T const&); | |
48 | #else | |
49 | template <typename T> | |
50 | Path(T const&, BOOST_DEDUCED_TYPENAME trait<T>::value_type* = 0); | |
51 | #endif | |
52 | ||
53 | }; | |
54 | #endif | |
55 | #endif | |
56 | ||
57 | ||
58 | int main() | |
59 | { | |
60 | #ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT | |
61 | #ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS | |
62 | ||
63 | boost::optional<Path> optFs1; | |
64 | boost::optional<Path> optFs2; | |
65 | ||
66 | optFs1 = optFs2; | |
67 | ||
68 | // the following still fails although it shouldn't | |
69 | //BOOST_STATIC_ASSERT((std::is_copy_constructible<boost::optional<Path>>::value)); | |
70 | ||
71 | #endif | |
72 | #endif | |
73 | } |