]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/integral_constant/constexpr_init.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / integral_constant / constexpr_init.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5#include <boost/hana/bool.hpp>
6#include <boost/hana/integral_constant.hpp>
7namespace hana = boost::hana;
8
9
10/*
11When we use `int_<...>` in a template, Clang 3.5 says:
12
13--------------------------------
14include/boost/hana/integral_constant.hpp:80:20: error: constexpr variable 'int_<1>' must be initialized by a constant expression
15 constexpr auto int_ = integral<int, i>;
16 ^ ~~~~~~~~~~~~~~~~
17test/integral/constexpr_bug.cpp:41:37: note: in instantiation of variable template specialization 'boost::hana::int_' requested here
18constexpr auto check_int() { return int_<1>; }
19 ^
20include/boost/hana/integral_constant.hpp:80:27: note: subexpression not valid in a constant expression
21 constexpr auto int_ = integral<int, i>;
22 ^
23include/boost/hana/integral_constant.hpp:80:27: note: in call to 'integral_type(integral)'
24--------------------------------
25
26if we define int_ & friends like
27
28 template <int i>
29 constexpr auto int_ = integral<int, i>;
30
31Instead, we do
32
33 template <int i>
34 constexpr decltype(integral<int, i>) int_{};
35
36which is equivalent but uglier. Note that everything works just fine when
37we're not in a template.
38*/
39
40template <typename T>
41constexpr auto check_int() { return hana::int_c<1>; }
42
43template <typename T>
44constexpr auto check_true() { return hana::true_c; }
45
46template <typename T>
47constexpr auto check_size_t() { return hana::size_c<0>; }
48
49
50int main() { }