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
63
64
65
66
67
68
69
70
71
72
|
#pragma once
#include <type_traits>
#include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/version.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
{
namespace detail
{
enum class Trait
{
TriviallyAvailable,
Available,
Unavailable
};
template <typename T,
template <typename>
class IsTriviallyAvailable,
template <typename>
class IsAvailable>
inline constexpr Trait trait()
{
return IsTriviallyAvailable<T>::value
? Trait::TriviallyAvailable
: IsAvailable<T>::value ? Trait::Available : Trait::Unavailable;
}
inline constexpr Trait common_trait_impl(Trait result)
{
return result;
}
template <typename... Traits>
inline constexpr Trait common_trait_impl(Trait result, Trait t, Traits... ts)
{
return static_cast<int>(t) > static_cast<int>(result) ? common_trait_impl(t, ts...)
: common_trait_impl(result, ts...);
}
template <typename... Traits>
inline constexpr Trait common_trait(Traits... ts)
{
return common_trait_impl(Trait::TriviallyAvailable, ts...);
}
template <typename... Ts>
struct traits
{
static constexpr Trait copy_constructible_trait =
common_trait(trait<Ts, is_trivially_copy_constructible, std::is_copy_constructible>()...);
static constexpr Trait move_constructible_trait =
common_trait(trait<Ts, is_trivially_move_constructible, std::is_move_constructible>()...);
static constexpr Trait copy_assignable_trait =
common_trait(copy_constructible_trait,
trait<Ts, is_trivially_copy_assignable, std::is_copy_assignable>()...);
static constexpr Trait move_assignable_trait =
common_trait(move_constructible_trait,
trait<Ts, is_trivially_move_assignable, std::is_move_assignable>()...);
static constexpr Trait destructible_trait =
common_trait(trait<Ts, std::is_trivially_destructible, std::is_destructible>()...);
};
} // namespace detail
} // namespace nostd
OPENTELEMETRY_END_NAMESPACE
|