-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathconstexpr.hpp
More file actions
62 lines (51 loc) · 1.95 KB
/
constexpr.hpp
File metadata and controls
62 lines (51 loc) · 1.95 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Eggs.Variant
//
// Copyright Agustin K-ballo Berge, Fusion Fenix 2014-2018
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef EGGS_VARIANT_TEST_CONSTEXPR_HPP
#define EGGS_VARIANT_TEST_CONSTEXPR_HPP
#include <initializer_list>
#include <type_traits>
#include <eggs/variant/detail/config/prefix.hpp>
#if EGGS_CXX11_HAS_CONSTEXPR
struct Constexpr
{
int x;
constexpr Constexpr() : x(0) {}
constexpr Constexpr(int i) : x(i) {}
# if EGGS_CXX14_HAS_CONSTEXPR
constexpr Constexpr(std::initializer_list<int> is) : x(*is.begin()) {}
# endif
constexpr Constexpr(Constexpr const& rhs) : x(rhs.x) {} // not trivially copyable
constexpr bool operator==(Constexpr rhs) const { return x == rhs.x; }
constexpr bool operator!=(Constexpr rhs) const { return x != rhs.x; }
constexpr bool operator<(Constexpr rhs) const { return x < rhs.x; }
constexpr bool operator>(Constexpr rhs) const { return x > rhs.x; }
constexpr bool operator<=(Constexpr rhs) const { return x <= rhs.x; }
constexpr bool operator>=(Constexpr rhs) const { return x >= rhs.x; }
};
# if !EGGS_CXX11_STD_HAS_IS_TRIVIALLY_DESTRUCTIBLE
namespace eggs { namespace variants { namespace detail
{
template <> struct is_trivially_destructible<Constexpr> : std::true_type {};
}}}
# endif
struct ConstexprTrivial
{
constexpr ConstexprTrivial() {}
constexpr ConstexprTrivial(int) {}
# if EGGS_CXX14_HAS_CONSTEXPR
constexpr ConstexprTrivial(std::initializer_list<int>) {}
# endif
};
# if !EGGS_CXX11_STD_HAS_IS_TRIVIALLY_COPYABLE || !EGGS_CXX11_STD_HAS_IS_TRIVIALLY_DESTRUCTIBLE
namespace eggs { namespace variants { namespace detail
{
template <> struct is_trivially_copyable<ConstexprTrivial> : std::true_type {};
template <> struct is_trivially_destructible<ConstexprTrivial> : std::true_type {};
}}}
# endif
#endif
#endif /*EGGS_VARIANT_TEST_CONSTEXPR_HPP*/