]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hof/test/rotate.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / hof / test / rotate.cpp
1 /*=============================================================================
2 Copyright (c) 2017 Paul Fultz II
3 rotate.cpp
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #include <boost/hof/rotate.hpp>
8 #include <boost/hof/placeholders.hpp>
9 #include <boost/hof/compose.hpp>
10 #include <boost/hof/repeat.hpp>
11 #include "test.hpp"
12
13 struct head
14 {
15 template<class T, class... Ts>
16 constexpr T operator()(T x, Ts&&...) const
17 BOOST_HOF_RETURNS_DEDUCE_NOEXCEPT(x)
18 {
19 return x;
20 }
21 };
22
23 #if BOOST_HOF_HAS_NOEXCEPT_DEDUCTION
24 BOOST_HOF_TEST_CASE()
25 {
26 static_assert(noexcept(boost::hof::rotate(head{})(1, 2, 3, 4)), "noexcept rotate");
27 static_assert(noexcept(boost::hof::repeat(std::integral_constant<int, 5>{})(boost::hof::rotate)(head{})(1, 2, 3, 4, 5, 6, 7, 8, 9)), "noexcept rotate");
28 }
29 #endif
30
31 BOOST_HOF_TEST_CASE()
32 {
33 BOOST_HOF_TEST_CHECK(2 == boost::hof::rotate(head{})(1, 2, 3, 4));
34 BOOST_HOF_STATIC_TEST_CHECK(2 == boost::hof::rotate(head{})(1, 2, 3, 4));
35 }
36
37 BOOST_HOF_TEST_CASE()
38 {
39 BOOST_HOF_TEST_CHECK(3 == boost::hof::compose(boost::hof::rotate, boost::hof::rotate)(head{})(1, 2, 3, 4));
40 BOOST_HOF_STATIC_TEST_CHECK(3 == boost::hof::compose(boost::hof::rotate, boost::hof::rotate)(head{})(1, 2, 3, 4));
41 }
42
43 BOOST_HOF_TEST_CASE()
44 {
45 BOOST_HOF_TEST_CHECK(6 == boost::hof::repeat(std::integral_constant<int, 5>{})(boost::hof::rotate)(head{})(1, 2, 3, 4, 5, 6, 7, 8, 9));
46 BOOST_HOF_STATIC_TEST_CHECK(6 == boost::hof::repeat(std::integral_constant<int, 5>{})(boost::hof::rotate)(head{})(1, 2, 3, 4, 5, 6, 7, 8, 9));
47 }
48
49 BOOST_HOF_TEST_CASE()
50 {
51 BOOST_HOF_TEST_CHECK(3 == boost::hof::rotate(boost::hof::_ - boost::hof::_)(2, 5));
52 BOOST_HOF_STATIC_TEST_CHECK(3 == boost::hof::rotate(boost::hof::_ - boost::hof::_)(2, 5));
53 }
54
55 #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
56 #define FINAL
57 #else
58 #define FINAL final
59 #endif
60
61
62 struct f FINAL {
63 int operator()(int i, void *) const {
64 return i;
65 }
66 };
67
68 BOOST_HOF_TEST_CASE()
69 {
70 BOOST_HOF_TEST_CHECK(boost::hof::rotate(f())(nullptr, 2) == 2);
71 }