1 //
2 // cpp14/prefer_unsupported.cpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #include <boost/asio/prefer.hpp>
12 #include <cassert>
13
14 template <int>
15 struct prop
16 {
17 template <typename> static constexpr bool is_applicable_property_v = true;
18 static constexpr bool is_preferable = true;
19 };
20
21 template <int>
22 struct object
23 {
24 };
25
main()26 int main()
27 {
28 object<1> o1 = {};
29 object<1> o2 = boost::asio::prefer(o1, prop<2>());
30 object<1> o3 = boost::asio::prefer(o1, prop<2>(), prop<3>());
31 object<1> o4 = boost::asio::prefer(o1, prop<2>(), prop<3>(), prop<4>());
32 (void)o2;
33 (void)o3;
34 (void)o4;
35
36 const object<1> o5 = {};
37 object<1> o6 = boost::asio::prefer(o5, prop<2>());
38 object<1> o7 = boost::asio::prefer(o5, prop<2>(), prop<3>());
39 object<1> o8 = boost::asio::prefer(o5, prop<2>(), prop<3>(), prop<4>());
40 (void)o6;
41 (void)o7;
42 (void)o8;
43
44 constexpr object<1> o9 = boost::asio::prefer(object<1>(), prop<2>());
45 constexpr object<1> o10 = boost::asio::prefer(object<1>(), prop<2>(), prop<3>());
46 constexpr object<1> o11 = boost::asio::prefer(object<1>(), prop<2>(), prop<3>(), prop<4>());
47 (void)o9;
48 (void)o10;
49 (void)o11;
50 }
51