Support std::vector of non-copyable types
This commit is contained in:
1 parent
35e4c6e889
commit
9df8d1be39
2 files changed
+32
No files matched your search
@@ -55,6 +55,26 @@
|
||||
|
||||
// This one will be different for GCC 5.7 if it's ever supported
|
||||
#define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
|
||||
|
||||
// GCC 5 < v < 8 has a bug in is_trivially_copy_constructible which breaks std::vector
|
||||
// for non-copyable types
|
||||
#elif (defined(__GNUC__) && __GNUC__ < 8 && \
|
||||
!defined(__clang__))
|
||||
namespace tl {
|
||||
namespace detail {
|
||||
template<class T>
|
||||
struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T>{};
|
||||
template<class T, class A>
|
||||
struct is_trivially_copy_constructible<std::vector<T,A>>
|
||||
: std::is_trivially_copy_constructible<T>{};
|
||||
}
|
||||
}
|
||||
|
||||
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
|
||||
tl::detail::is_trivially_copy_constructible<T>::value
|
||||
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
|
||||
std::is_trivially_copy_assignable<T>::value
|
||||
#define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
|
||||
#else
|
||||
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
|
||||
std::is_trivially_copy_constructible<T>::value
|
||||
|
||||
Reference in new issue
Block a user