rippled
ripple
beast
hash
meta.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of Beast: https://github.com/vinniefalco/Beast
4
Copyright 2014, Howard Hinnant <howard.hinnant@gmail.com>
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef BEAST_HASH_META_H_INCLUDED
21
#define BEAST_HASH_META_H_INCLUDED
22
23
#include <
type_traits
>
24
25
namespace
beast
{
26
27
template
<
bool
...>
struct
static_and
;
28
29
template
<
bool
b0,
bool
... bN>
30
struct
static_and
<b0, bN...>
31
:
public
std::integral_constant
<
32
bool, b0 && static_and<bN...>::value>
33
{
34
explicit
static_and
() =
default
;
35
};
36
37
template
<>
38
struct
static_and
<>
39
:
public
std::true_type
40
{
41
explicit
static_and
() =
default
;
42
};
43
44
#ifndef __INTELLISENSE__
45
static_assert(
static_and<true, true, true>::value
,
""
);
46
static_assert(!
static_and<true, false, true>::value
,
""
);
47
#endif
48
49
template
<
std::size_t
...>
50
struct
static_sum
;
51
52
template
<
std::size_t
s0,
std::size_t
...sN>
53
struct
static_sum
<s0, sN...>
54
:
public
std::integral_constant
<
55
std::size_t, s0 + static_sum<sN...>::value>
56
{
57
explicit
static_sum
() =
default
;
58
};
59
60
template
<>
61
struct
static_sum
<>
62
:
public
std::integral_constant
<std::size_t, 0>
63
{
64
explicit
static_sum
() =
default
;
65
};
66
67
#ifndef __INTELLISENSE__
68
static_assert(
static_sum<5, 2, 17, 0>::value
== 24,
""
);
69
#endif
70
71
template
<
class
T,
class
U>
72
struct
enable_if_lvalue
73
:
public
std::enable_if
74
<
75
std::is_same<std::decay_t<T>, U>::value &&
76
std::is_lvalue_reference<T>::value
77
>
78
{
79
explicit
enable_if_lvalue
() =
default
;
80
};
81
144
template
<
class
T,
class
U>
145
using
enable_if_lvalue_t
=
typename
enable_if_lvalue<T, U>::type
;
146
147
}
// beast
148
149
#endif // BEAST_UTILITY_META_H_INCLUDED
std::integral_constant
beast::static_and
Definition:
meta.h:27
std::enable_if
beast::enable_if_lvalue_t
typename enable_if_lvalue< T, U >::type enable_if_lvalue_t
Ensure const reference function parameters are valid lvalues.
Definition:
meta.h:145
beast::static_sum
Definition:
meta.h:50
beast::enable_if_lvalue::enable_if_lvalue
enable_if_lvalue()=default
std::size_t
type_traits
beast::enable_if_lvalue
Definition:
meta.h:72
beast
Definition:
base_uint.h:582
Generated by
1.8.17