mirror of
https://github.com/TartanLlama/expected.git
synced 2025-08-03 19:04:29 +02:00
Fix #29
This commit is contained in:
@@ -30,3 +30,16 @@ TEST_CASE("Issue 26", "[issues.26]") {
|
|||||||
tl::expected<a, int> exp = tl::expected<b,int>(tl::unexpect, 0);
|
tl::expected<a, int> exp = tl::expected<b,int>(tl::unexpect, 0);
|
||||||
REQUIRE(!exp.has_value());
|
REQUIRE(!exp.has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct foo {
|
||||||
|
foo() = default;
|
||||||
|
foo(foo&) = delete;
|
||||||
|
foo(foo&&) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("Issue 29", "[issues.29]") {
|
||||||
|
std::vector<foo> v;
|
||||||
|
v.emplace_back();
|
||||||
|
tl::expected<std::vector<foo>, int> ov = std::move(v);
|
||||||
|
REQUIRE(ov->size() == 1);
|
||||||
|
}
|
||||||
|
@@ -70,6 +70,29 @@
|
|||||||
/// \exclude
|
/// \exclude
|
||||||
#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \
|
#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \
|
||||||
std::is_trivially_destructible<T>
|
std::is_trivially_destructible<T>
|
||||||
|
|
||||||
|
// 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__))
|
||||||
|
#ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
|
||||||
|
#define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
|
||||||
|
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>{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
|
||||||
|
tl::detail::is_trivially_copy_constructible<T>
|
||||||
|
#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
|
||||||
|
std::is_trivially_copy_assignable<T>
|
||||||
|
#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>
|
||||||
#else
|
#else
|
||||||
/// \exclude
|
/// \exclude
|
||||||
#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
|
#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
|
||||||
|
Reference in New Issue
Block a user