bit::memory
Stateless.hpp
1 /*****************************************************************************
2  * \file
3  * \brief This header contains the definitions for the 'Stateless' concepts and
4  * related type-traits
5  *****************************************************************************/
6 
7 /*
8  The MIT License (MIT)
9 
10  Copyright (c) 2018 Matthew Rodusek
11 
12  Permission is hereby granted, free of charge, to any person obtaining a copy
13  of this software and associated documentation files (the "Software"), to deal
14  in the Software without restriction, including without limitation the rights
15  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the Software is
17  furnished to do so, subject to the following conditions:
18 
19  The above copyright notice and this permission notice shall be included in
20  all copies or substantial portions of the Software.
21 
22  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  SOFTWARE.
29 */
30 #ifndef BIT_MEMORY_CONCEPTS_STATELESS_HPP
31 #define BIT_MEMORY_CONCEPTS_STATELESS_HPP
32 
33 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
34 # pragma once
35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
36 
37 #include "detail/void_t.hpp" // detail::void_t
38 
39 #include <type_traits> // std::integral_constants
40 
41 namespace bit {
42  namespace memory {
43 
94 #if __cplusplus >= 202000L
95  // TODO(bitwize) replace 202000L with the correct __cplusplus when certified
96 
97  template<typename T>
98  concept bool Stateless = std::is_empty<T>::value
99  && std::is_trivially_constructible<T>::value
100  && std::is_trivially_destructible<T>::value
101  && std::is_trivially_move_constructible<T>::value
102  && std::is_trivially_copy_constructible<T>::value
103  && std::is_trivially_copy_assignable<T>::value
104  && std::is_trivially_move_assignable<T>::value
105  && std::is_trivial<T>::value
106 
107 #endif
108 
115  template<typename T>
116  struct is_stateless : std::integral_constant<bool,
117  std::is_empty<T>::value &&
118  std::is_trivially_constructible<T>::value &&
119  std::is_trivially_destructible<T>::value &&
120  std::is_trivially_move_constructible<T>::value &&
121  std::is_trivially_copy_constructible<T>::value &&
122  std::is_trivially_copy_assignable<T>::value &&
123  std::is_trivially_move_assignable<T>::value &&
124  std::is_trivial<T>::value
125  >{};
126 
130  template<typename T>
131  constexpr bool is_stateless_v = is_stateless<T>::value;
132 
133  } // namespace memory
134 } // namespace bit
135 
136 #endif /* BIT_MEMORY_CONCEPTS_STATELESS_HPP */
Type-trait to check for whether a given type T is Stateless.
Definition: Stateless.hpp:116