Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / histogram / test / detail_compressed_pair_test.cpp
1 // Copyright 2019 Hans Dembinski
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <boost/core/lightweight_test.hpp>
8 #include <boost/core/lightweight_test_trait.hpp>
9 #include <boost/histogram/detail/compressed_pair.hpp>
10 #include "std_ostream.hpp"
11
12 using namespace boost::histogram::detail;
13
14 struct nothrow_move {
15   nothrow_move(nothrow_move&&) noexcept {}
16   nothrow_move& operator=(nothrow_move&&) noexcept { return *this; }
17 };
18
19 struct throw_move {
20   throw_move(throw_move&&) {}
21   throw_move& operator=(throw_move&&) { return *this; }
22 };
23
24 int main() {
25   BOOST_TEST_TRAIT_TRUE(
26       (std::is_nothrow_move_constructible<compressed_pair<nothrow_move, nothrow_move> >));
27
28   BOOST_TEST_TRAIT_FALSE(
29       (std::is_nothrow_move_constructible<compressed_pair<nothrow_move, throw_move> >));
30
31   BOOST_TEST_TRAIT_FALSE(
32       (std::is_nothrow_move_constructible<compressed_pair<throw_move, nothrow_move> >));
33
34   BOOST_TEST_TRAIT_FALSE(
35       (std::is_nothrow_move_constructible<compressed_pair<throw_move, throw_move> >));
36
37   BOOST_TEST_GE(sizeof(compressed_pair<int, char>), sizeof(int) + sizeof(char));
38   BOOST_TEST_EQ(sizeof(compressed_pair<int, nothrow_move>), sizeof(int));
39   BOOST_TEST_EQ(sizeof(compressed_pair<int, throw_move>), sizeof(int));
40
41   return boost::report_errors();
42 }