mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
for vs2015 error C3256
This commit is contained in:
parent
e20dd7d5e3
commit
e5bf3b7c84
@ -3,6 +3,7 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "libipc/platform/detail.h"
|
||||||
#include "libipc/utility/concept.h"
|
#include "libipc/utility/concept.h"
|
||||||
#include "libipc/pool_alloc.h"
|
#include "libipc/pool_alloc.h"
|
||||||
|
|
||||||
@ -17,49 +18,45 @@ template <typename T, typename R = T*>
|
|||||||
using IsImplUncomfortable = ipc::require<(sizeof(T) > sizeof(T*)), R>;
|
using IsImplUncomfortable = ipc::require<(sizeof(T) > sizeof(T*)), R>;
|
||||||
|
|
||||||
template <typename T, typename... P>
|
template <typename T, typename... P>
|
||||||
constexpr auto make_impl(P&&... params) -> IsImplComfortable<T> {
|
IPC_CONSTEXPR_ auto make_impl(P&&... params) -> IsImplComfortable<T> {
|
||||||
T* buf {};
|
T* buf {};
|
||||||
::new (&buf) T { std::forward<P>(params)... };
|
::new (&buf) T { std::forward<P>(params)... };
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto impl(T* const (& p)) -> IsImplComfortable<T> {
|
IPC_CONSTEXPR_ auto impl(T* const (& p)) -> IsImplComfortable<T> {
|
||||||
return reinterpret_cast<T*>(&const_cast<char &>(reinterpret_cast<char const &>(p)));
|
return reinterpret_cast<T*>(&const_cast<char &>(reinterpret_cast<char const &>(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto clear_impl(T* p) -> IsImplComfortable<T, void> {
|
IPC_CONSTEXPR_ auto clear_impl(T* p) -> IsImplComfortable<T, void> {
|
||||||
if (p != nullptr) impl(p)->~T();
|
if (p != nullptr) impl(p)->~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... P>
|
template <typename T, typename... P>
|
||||||
constexpr auto make_impl(P&&... params) -> IsImplUncomfortable<T> {
|
IPC_CONSTEXPR_ auto make_impl(P&&... params) -> IsImplUncomfortable<T> {
|
||||||
return mem::alloc<T>(std::forward<P>(params)...);
|
return mem::alloc<T>(std::forward<P>(params)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto clear_impl(T* p) -> IsImplUncomfortable<T, void> {
|
IPC_CONSTEXPR_ auto clear_impl(T* p) -> IsImplUncomfortable<T, void> {
|
||||||
mem::free(p);
|
mem::free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto impl(T* const (& p)) -> IsImplUncomfortable<T> {
|
IPC_CONSTEXPR_ auto impl(T* const (& p)) -> IsImplUncomfortable<T> {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct pimpl {
|
struct pimpl {
|
||||||
template <typename... P>
|
template <typename... P>
|
||||||
constexpr static T* make(P&&... params) {
|
IPC_CONSTEXPR_ static T* make(P&&... params) {
|
||||||
return make_impl<T>(std::forward<P>(params)...);
|
return make_impl<T>(std::forward<P>(params)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
IPC_CONSTEXPR_ void clear() {
|
||||||
constexpr void clear() {
|
|
||||||
#else /*__cplusplus < 201703L*/
|
|
||||||
void clear() {
|
|
||||||
#endif/*__cplusplus < 201703L*/
|
|
||||||
clear_impl(static_cast<T*>(const_cast<pimpl*>(this)));
|
clear_impl(static_cast<T*>(const_cast<pimpl*>(this)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user