rippled
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...>
28 struct static_and;
29 
30 template <bool b0, bool... bN>
31 struct static_and<b0, bN...>
32  : public std::integral_constant<bool, b0 && static_and<bN...>::value>
33 {
34  explicit static_and() = default;
35 };
36 
37 template <>
38 struct static_and<> : public std::true_type
39 {
40  explicit static_and() = default;
41 };
42 
43 #ifndef __INTELLISENSE__
44 static_assert(static_and<true, true, true>::value, "");
45 static_assert(!static_and<true, false, true>::value, "");
46 #endif
47 
48 template <std::size_t...>
49 struct static_sum;
50 
51 template <std::size_t s0, std::size_t... sN>
52 struct static_sum<s0, sN...>
53  : public std::integral_constant<std::size_t, s0 + static_sum<sN...>::value>
54 {
55  explicit static_sum() = default;
56 };
57 
58 template <>
59 struct static_sum<> : public std::integral_constant<std::size_t, 0>
60 {
61  explicit static_sum() = default;
62 };
63 
64 #ifndef __INTELLISENSE__
65 static_assert(static_sum<5, 2, 17, 0>::value == 24, "");
66 #endif
67 
68 template <class T, class U>
70  std::is_same<std::decay_t<T>, U>::value &&
71  std::is_lvalue_reference<T>::value>
72 {
73  explicit enable_if_lvalue() = default;
74 };
75 
138 template <class T, class U>
140 
141 } // namespace beast
142 
143 #endif // BEAST_UTILITY_META_H_INCLUDED
std::integral_constant
beast::static_and
Definition: meta.h:28
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:139
beast::static_sum
Definition: meta.h:49
beast::enable_if_lvalue::enable_if_lvalue
enable_if_lvalue()=default
std::size_t
type_traits
beast::enable_if_lvalue
Definition: meta.h:69
beast
Definition: base_uint.h:646