PMDK C++ bindings  1.11
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 
16 
17 namespace pmem
18 {
19 
20 namespace detail
21 {
22 
23 template <typename... Ts>
24 struct make_void {
25  typedef void type;
26 };
27 template <typename... Ts>
28 using void_t = typename make_void<Ts...>::type;
29 
30 /* Generic SFINAE helper for expression checks, based on the idea demonstrated
31  * in ISO C++ paper n4502 */
32 template <typename T, typename, template <typename> class... Checks>
33 struct supports_impl {
34  using type = std::false_type;
35 };
36 template <typename T, template <typename> class... Checks>
37 struct supports_impl<T, void_t<Checks<T>...>, Checks...> {
38  using type = std::true_type;
39 };
40 
41 template <typename T, template <typename> class... Checks>
42 using supports = typename supports_impl<T, void, Checks...>::type;
43 
44 template <typename Compare>
45 using is_transparent = typename Compare::is_transparent;
46 
47 template <typename Compare>
48 using has_is_transparent = detail::supports<Compare, is_transparent>;
49 
50 /* Check if type is pmem::obj::basic_string or
51  * pmem::obj::basic_inline_string */
52 template <typename>
53 struct is_string : std::false_type {
54 };
55 
56 template <typename CharT, typename Traits>
57 struct is_string<obj::basic_string<CharT, Traits>> : std::true_type {
58 };
59 
60 template <typename CharT, typename Traits>
61 struct is_string<obj::experimental::basic_inline_string<CharT, Traits>>
62  : std::true_type {
63 };
64 
65 } /* namespace detail */
66 
67 } /* namespace pmem */
68 
69 #endif /* LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP */
Inline string implementation.
Persistent memory namespace.
Definition: allocation_flag.hpp:14
String container with std::basic_string compatible interface.