summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/multiprecision/test/test_optional_compat.cpp
blob: 4626f9ccd240167970bad8fbf4fc4acd8e7a7aa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 *  (c) Copyright Andrey Semashev 2018.
 *
 *  Use, modification and distribution are subject to the
 *  Boost Software License, Version 1.0. (See accompanying file
 *  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 */
/*
 * The test verifies that Boost.Multiprecision does not cause conflict with Boost.Optional
 * because of its restricted conversion constructors and operators. See comments in:
 *
 * https://github.com/boostorg/integer/pull/11
 */

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional/optional.hpp>
#include <boost/core/lightweight_test.hpp>

inline boost::optional<boost::multiprecision::int128_t> foo()
{
   return boost::optional<boost::multiprecision::int128_t>(10);
}

int main()
{
   boost::optional<boost::multiprecision::int128_t> num = foo();
   BOOST_TEST(!!num);
   BOOST_TEST(*num == 10);

   return boost::report_errors();
}