mirror of
https://github.com/TartanLlama/optional.git
synced 2025-08-04 04:14:25 +02:00
Support std::vector of non-copyable types
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
#include "catch.hpp"
|
||||
#include "optional.hpp"
|
||||
#include <vector>
|
||||
|
||||
struct foo {
|
||||
foo() = default;
|
||||
foo(foo&) = delete;
|
||||
foo(foo&&) {};
|
||||
};
|
||||
|
||||
TEST_CASE("Constructors", "[constructors]") {
|
||||
tl::optional<int> o1;
|
||||
@@ -47,4 +54,9 @@ TEST_CASE("Constructors", "[constructors]") {
|
||||
REQUIRE(oo);
|
||||
REQUIRE(*oo == 42);
|
||||
}
|
||||
|
||||
std::vector<foo> v;
|
||||
v.emplace_back();
|
||||
tl::optional<std::vector<foo>> ov = std::move(v);
|
||||
REQUIRE(ov->size() == 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user