mdds
Toggle main menu visibility
Loading...
Searching...
No Matches
include
mdds
global.hpp
1
// SPDX-FileCopyrightText: 2008 - 2025 Kohei Yoshida
2
//
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#include <exception>
8
#include <string>
9
#include <memory>
10
#include <utility>
11
#include <type_traits>
12
23
#define MDDS_ASCII(literal) literal, sizeof(literal) - 1
24
33
#define MDDS_N_ELEMENTS(name) sizeof(name) / sizeof(name[0])
34
35
#define MDDS_DEPRECATED [[deprecated]]
36
37
#ifndef MDDS_LOOP_UNROLLING
38
#define MDDS_LOOP_UNROLLING 1
39
#endif
40
41
#ifndef MDDS_USE_OPENMP
42
#define MDDS_USE_OPENMP 0
43
#endif
44
45
#if defined(__AVX__) || defined(__AVX2__)
46
#ifndef __SSE2__
47
#define __SSE2__ 1
48
#endif
49
#endif
50
51
namespace
mdds {
52
53
class
general_error :
public
::std::exception
54
{
55
public
:
56
general_error(const ::std::string& msg) : m_msg(msg)
57
{}
58
virtual
~general_error()
noexcept
59
{}
60
61
virtual
const
char
* what()
const
noexcept
62
{
63
return
m_msg.c_str();
64
}
65
66
private
:
67
::std::string m_msg;
68
};
69
70
class
invalid_arg_error :
public
general_error
71
{
72
public
:
73
invalid_arg_error(const ::std::string& msg) : general_error(msg)
74
{}
75
};
76
77
class
size_error :
public
general_error
78
{
79
public
:
80
size_error(
const
std::string& msg) : general_error(msg)
81
{}
82
};
83
84
class
type_error :
public
general_error
85
{
86
public
:
87
type_error(
const
std::string& msg) : general_error(msg)
88
{}
89
};
90
91
class
integrity_error :
public
general_error
92
{
93
public
:
94
integrity_error(
const
std::string& msg) : general_error(msg)
95
{}
96
};
97
98
namespace
detail {
99
100
template
<
typename
T>
101
concept
has_value_type
=
requires
{
typename
T::value_type; };
102
103
template
<
typename
T,
typename
IsConst>
104
struct
const_or_not
;
105
106
template
<
typename
T>
107
struct
const_or_not
<T, std::true_type>
108
{
109
using
type =
typename
std::add_const<T>::type;
110
};
111
112
template
<
typename
T>
113
struct
const_or_not
<T, std::false_type>
114
{
115
using
type = T;
116
};
117
118
template
<
typename
T,
bool
Const>
119
using
const_t =
typename
const_or_not<T, std::bool_constant<Const>
>::type;
120
121
template
<
typename
T,
typename
Mutable>
122
struct
mutable_or_not
;
123
124
template
<
typename
T>
125
struct
mutable_or_not
<T, std::true_type>
126
{
127
using
type = T;
128
};
129
130
template
<
typename
T>
131
struct
mutable_or_not
<T, std::false_type>
132
{
133
using
type =
typename
std::add_const<T>::type;
134
};
135
136
template
<
typename
T,
bool
Mutable>
137
using
mutable_t =
typename
mutable_or_not<T, std::bool_constant<Mutable>
>::type;
138
139
template
<
typename
T,
typename
IsConst>
140
struct
get_iterator_type
;
141
142
template
<
typename
T>
143
struct
get_iterator_type
<T, std::true_type>
144
{
145
using
type =
typename
T::const_iterator;
146
};
147
148
template
<
typename
T>
149
struct
get_iterator_type
<T, std::false_type>
150
{
151
using
type =
typename
T::iterator;
152
};
153
154
template
<
int
T>
155
constexpr
bool
invalid_static_int()
156
{
157
return
false
;
158
}
159
168
template
<
typename
T>
169
concept
is_complete
=
requires
{
sizeof
(T); };
170
171
}
// namespace detail
172
173
}
// namespace mdds
mdds::detail::has_value_type
Definition
global.hpp:101
mdds::detail::is_complete
Definition
global.hpp:169
mdds::detail::const_or_not
Definition
global.hpp:104
mdds::detail::get_iterator_type
Definition
global.hpp:140
mdds::detail::mutable_or_not
Definition
global.hpp:122
Generated on
for mdds by
1.17.0