PMDK C++ bindings  1.12-git53.g67ba2be4
This is the C++ bindings documentation for PMDK's libpmemobj.
template_helpers.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2019-2020, Intel Corporation */
3 
9 #ifndef LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP
10 #define LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP
11 
12 #include <type_traits>
13 
14 namespace pmem
15 {
16 
17 namespace detail
18 {
19 
20 template <typename... Ts>
21 struct make_void {
22  typedef void type;
23 };
24 template <typename... Ts>
25 using void_t = typename make_void<Ts...>::type;
26 
27 /* Generic SFINAE helper for expression checks, based on the idea demonstrated
28  * in ISO C++ paper n4502 */
29 template <typename T, typename, template <typename> class... Checks>
30 struct supports_impl {
31  using type = std::false_type;
32 };
33 template <typename T, template <typename> class... Checks>
34 struct supports_impl<T, void_t<Checks<T>...>, Checks...> {
35  using type = std::true_type;
36 };
37 
38 template <typename T, template <typename> class... Checks>
39 using supports = typename supports_impl<T, void, Checks...>::type;
40 
41 template <typename Compare>
42 using is_transparent = typename Compare::is_transparent;
43 
44 template <typename Compare>
45 using has_is_transparent = detail::supports<Compare, is_transparent>;
46 
47 } /* namespace detail */
48 
49 } /* namespace pmem */
50 
51 #endif /* LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP */
pmem
Persistent memory namespace.
Definition: allocation_flag.hpp:15