• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2Copyright 2018 T. Zachary Laine
3(whatwasthataddress@gmail.com)
4
5Distributed under Boost Software License, Version 1.0.
6(See accompanying file LICENSE_1_0.txt or copy at
7http://www.boost.org/LICENSE_1_0.txt)
8*/
9
10// MACRO: BOOST_NO_CXX17_IF_CONSTEXPR
11// TITLE: C++17 if constexpr
12// DESCRIPTION: C++17 if constexpr are not supported.
13
14namespace boost_no_cxx17_if_constexpr {
15
16template <typename T, typename U>
17struct same
18{
19    static constexpr bool value = false;
20};
21
22template <typename T>
23struct same<T, T>
24{
25    static constexpr bool value = true;
26};
27
28int test()
29{
30    if constexpr (true) {
31        if constexpr (1 != 0) {
32            if constexpr (same<int, double>::value) {
33                static_assert(!same<int, double>::value, "");
34                return 1;
35            } else if constexpr (false) {
36                return 1;
37            } else {
38                return 0;
39            }
40        }
41    }
42    return 1;
43}
44
45}
46