]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/config/test/boost_no_cxx14_constexpr.ipp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / config / test / boost_no_cxx14_constexpr.ipp
CommitLineData
7c673cae 1
b32b8144 2// (C) Copyright Kohei Takahashi 2014,2016
7c673cae
FG
3
4// Use, modification and distribution are subject to the
5// Boost Software License, Version 1.0. (See accompanying file
6// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8// See http://www.boost.org/libs/config for more information.
9
10// MACRO: BOOST_NO_CXX14_CONSTEXPR
11// TITLE: C++14 relaxed constexpr unavailable
12// DESCRIPTION: The compiler does not support C++14 relaxed constexpr
13
14namespace boost_no_cxx14_constexpr
15{
16
17namespace detail
18{
19 template <class> struct void_ { typedef void type; };
b32b8144
FG
20
21 struct non_tmpl
22 {
23 constexpr int foo() const { return 1; }
24 constexpr int foo() { return 0; }
25 };
26
27 template <typename T>
28 struct tmpl : non_tmpl { };
7c673cae
FG
29}
30
31// Test relaxed constexpr with dependent type; for more details, see comment of
32// BOOST_CXX14_CONSTEXPR definition in boost/config/compiler/clang.hpp .
33template <class T>
34constexpr typename detail::void_<T>::type decrement(T &value)
35{
36 --value;
37}
38
b32b8144
FG
39constexpr int non_cv_member(detail::non_tmpl x)
40{
41 return x.foo();
42}
43
44template <typename T>
45constexpr int non_cv_member(detail::tmpl<T> x)
46{
47 return x.foo();
48}
49
7c673cae
FG
50constexpr int zero()
51{
52 int ret = 1;
53 decrement(ret);
54 return ret;
55}
56
b32b8144
FG
57template <int v> struct compile_time_value
58{
59 static constexpr int value = v;
60};
61
7c673cae
FG
62int test()
63{
b32b8144
FG
64 return compile_time_value<
65 zero()
66 + non_cv_member(detail::non_tmpl())
67 + non_cv_member(detail::tmpl<int>())
68 >::value;
7c673cae
FG
69}
70
71}
72