-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathutil.hpp
More file actions
107 lines (87 loc) · 3.01 KB
/
util.hpp
File metadata and controls
107 lines (87 loc) · 3.01 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// MPark.Variant
//
// Copyright Michael Park, 2015-2017
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <mpark/config.hpp>
enum Qual { Ptr, ConstPtr, LRef, ConstLRef, RRef, ConstRRef };
struct get_qual_t {
constexpr Qual operator()(int *) const { return Ptr; }
constexpr Qual operator()(const int *) const { return ConstPtr; }
constexpr Qual operator()(int &) const { return LRef; }
constexpr Qual operator()(const int &) const { return ConstLRef; }
constexpr Qual operator()(int &&) const { return RRef; }
constexpr Qual operator()(const int &&) const { return ConstRRef; }
};
constexpr get_qual_t get_qual{};
#ifdef MPARK_EXCEPTIONS
struct CopyConstruction : std::exception {};
struct CopyAssignment : std::exception {};
struct MoveConstruction : std::exception {};
struct MoveAssignment : std::exception {};
struct copy_thrower_t {
constexpr copy_thrower_t() {}
[[noreturn]] copy_thrower_t(const copy_thrower_t &) {
throw CopyConstruction{};
}
copy_thrower_t(copy_thrower_t &&) = default;
copy_thrower_t &operator=(const copy_thrower_t &) { throw CopyAssignment{}; }
copy_thrower_t &operator=(copy_thrower_t &&) = default;
};
inline bool operator<(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return false;
}
inline bool operator>(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return false;
}
inline bool operator<=(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return true;
}
inline bool operator>=(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return true;
}
inline bool operator==(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return true;
}
inline bool operator!=(const copy_thrower_t &,
const copy_thrower_t &) noexcept {
return false;
}
struct move_thrower_t {
constexpr move_thrower_t() {}
move_thrower_t(const move_thrower_t &) = default;
[[noreturn]] move_thrower_t(move_thrower_t &&) { throw MoveConstruction{}; }
move_thrower_t &operator=(const move_thrower_t &) = default;
move_thrower_t &operator=(move_thrower_t &&) { throw MoveAssignment{}; }
};
inline bool operator<(const move_thrower_t &,
const move_thrower_t &) noexcept {
return false;
}
inline bool operator>(const move_thrower_t &,
const move_thrower_t &) noexcept {
return false;
}
inline bool operator<=(const move_thrower_t &,
const move_thrower_t &) noexcept {
return true;
}
inline bool operator>=(const move_thrower_t &,
const move_thrower_t &) noexcept {
return true;
}
inline bool operator==(const move_thrower_t &,
const move_thrower_t &) noexcept {
return true;
}
inline bool operator!=(const move_thrower_t &,
const move_thrower_t &) noexcept {
return false;
}
#endif