3
3
#include < new>
4
4
#include < utility>
5
5
6
+ #include " libipc/platform/detail.h"
6
7
#include " libipc/utility/concept.h"
7
8
#include " libipc/pool_alloc.h"
8
9
@@ -17,49 +18,45 @@ template <typename T, typename R = T*>
17
18
using IsImplUncomfortable = ipc::require<(sizeof (T) > sizeof (T*)), R>;
18
19
19
20
template <typename T, typename ... P>
20
- constexpr auto make_impl (P&&... params) -> IsImplComfortable<T> {
21
+ IPC_CONSTEXPR_ auto make_impl (P&&... params) -> IsImplComfortable<T> {
21
22
T* buf {};
22
23
::new (&buf) T { std::forward<P>(params)... };
23
24
return buf;
24
25
}
25
26
26
27
template <typename T>
27
- constexpr auto impl (T* const (& p)) -> IsImplComfortable<T> {
28
+ IPC_CONSTEXPR_ auto impl (T* const (& p)) -> IsImplComfortable<T> {
28
29
return reinterpret_cast <T*>(&const_cast <char &>(reinterpret_cast <char const &>(p)));
29
30
}
30
31
31
32
template <typename T>
32
- constexpr auto clear_impl (T* p) -> IsImplComfortable<T, void> {
33
+ IPC_CONSTEXPR_ auto clear_impl (T* p) -> IsImplComfortable<T, void> {
33
34
if (p != nullptr ) impl (p)->~T ();
34
35
}
35
36
36
37
template <typename T, typename ... P>
37
- constexpr auto make_impl (P&&... params) -> IsImplUncomfortable<T> {
38
+ IPC_CONSTEXPR_ auto make_impl (P&&... params) -> IsImplUncomfortable<T> {
38
39
return mem::alloc<T>(std::forward<P>(params)...);
39
40
}
40
41
41
42
template <typename T>
42
- constexpr auto clear_impl (T* p) -> IsImplUncomfortable<T, void> {
43
+ IPC_CONSTEXPR_ auto clear_impl (T* p) -> IsImplUncomfortable<T, void> {
43
44
mem::free (p);
44
45
}
45
46
46
47
template <typename T>
47
- constexpr auto impl (T* const (& p)) -> IsImplUncomfortable<T> {
48
+ IPC_CONSTEXPR_ auto impl (T* const (& p)) -> IsImplUncomfortable<T> {
48
49
return p;
49
50
}
50
51
51
52
template <typename T>
52
53
struct pimpl {
53
54
template <typename ... P>
54
- constexpr static T* make (P&&... params) {
55
+ IPC_CONSTEXPR_ static T* make (P&&... params) {
55
56
return make_impl<T>(std::forward<P>(params)...);
56
57
}
57
58
58
- #if __cplusplus >= 201703L
59
- constexpr void clear () {
60
- #else /* __cplusplus < 201703L*/
61
- void clear () {
62
- #endif/* __cplusplus < 201703L*/
59
+ IPC_CONSTEXPR_ void clear () {
63
60
clear_impl (static_cast <T*>(const_cast <pimpl*>(this )));
64
61
}
65
62
};
0 commit comments