-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.h
93 lines (67 loc) · 2.6 KB
/
default.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// std:: unique_ptr, shared_ptr, weak_ptr, basic_string, pair
// boost:: intrusive_ptr, local_shared_ptr, circular_buffer, variant, polymorphic_allocator
/** @file
* @brief This is included by dynarray.h, so should not be needed in user code
*/
#include "../auxi/core_util.h"
#include <memory>
#if __has_include(<boost/config.hpp>)
#define OEL_HAS_BOOST 1
#else
#define OEL_HAS_BOOST 0
#endif
#if OEL_HAS_BOOST
#include <boost/circular_buffer_fwd.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/variant/variant_fwd.hpp>
namespace boost
{
template< typename T > class intrusive_ptr;
template< typename T > class local_shared_ptr;
}
#endif
// std::string in GNU library is not trivially relocatable (uses pointer to internal buffer)
#if defined _CPPLIB_VER or defined _LIBCPP_VERSION
#include <string>
template< typename C, typename Tr, typename Alloc >
struct oel::is_trivially_relocatable< std::basic_string<C, Tr, Alloc> >
: bool_constant<
is_trivially_relocatable<Alloc>::value and
is_trivially_relocatable< typename std::allocator_traits<Alloc>::pointer >::value
> {};
#endif
namespace oel
{
template< typename T >
struct is_trivially_relocatable< std::allocator<T> > : true_type {};
template< typename T, typename Del >
struct is_trivially_relocatable< std::unique_ptr<T, Del> >
: is_trivially_relocatable<Del> {};
template< typename T >
struct is_trivially_relocatable< std::shared_ptr<T> > : true_type {};
template< typename T >
struct is_trivially_relocatable< std::weak_ptr<T> > : true_type {};
#if OEL_HAS_BOOST
template< typename T >
struct is_trivially_relocatable< boost::container::pmr::polymorphic_allocator<T> > : true_type {};
template< typename T >
struct is_trivially_relocatable< boost::intrusive_ptr<T> > : true_type {};
template< typename T >
struct is_trivially_relocatable< boost::local_shared_ptr<T> > : true_type {};
template< typename T, typename Alloc >
struct is_trivially_relocatable< boost::circular_buffer<T, Alloc> >
: bool_constant<
is_trivially_relocatable<Alloc>::value and
is_trivially_relocatable< typename std::allocator_traits<Alloc>::pointer >::value
> {};
template< typename... Ts >
struct is_trivially_relocatable< boost::variant<Ts...> >
: std::conjunction< is_trivially_relocatable<Ts>... > {};
#endif
template< typename T, typename U >
struct is_trivially_relocatable< std::pair<T, U> >
: std::conjunction< is_trivially_relocatable<T>, is_trivially_relocatable<U> > {};
}