Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/libcxx/ranges/range.nonprop.cache/ctor.move.pass.cpp
Show All 28 Lines | |||||
template <class T> | template <class T> | ||||
constexpr void test() { | constexpr void test() { | ||||
using Cache = std::ranges::__non_propagating_cache<T>; | using Cache = std::ranges::__non_propagating_cache<T>; | ||||
static_assert(std::is_nothrow_move_constructible_v<Cache>); | static_assert(std::is_nothrow_move_constructible_v<Cache>); | ||||
// Test with direct initialization | // Test with direct initialization | ||||
{ | { | ||||
Cache a; | Cache a; | ||||
a.__set(T{3}); | a.__emplace(3); | ||||
Cache b(std::move(a)); | Cache b(std::move(a)); | ||||
assert(!b.__has_value()); // make sure we don't propagate | assert(!b.__has_value()); // make sure we don't propagate | ||||
assert(!a.__has_value()); // make sure we disengage the source | assert(!a.__has_value()); // make sure we disengage the source | ||||
} | } | ||||
// Test with copy initialization | // Test with copy initialization | ||||
{ | { | ||||
Cache a; | Cache a; | ||||
a.__set(T{3}); | a.__emplace(3); | ||||
Cache b = std::move(a); | Cache b = std::move(a); | ||||
assert(!b.__has_value()); // make sure we don't propagate | assert(!b.__has_value()); // make sure we don't propagate | ||||
assert(!a.__has_value()); // make sure we disengage the source | assert(!a.__has_value()); // make sure we disengage the source | ||||
} | } | ||||
} | } | ||||
constexpr bool tests() { | constexpr bool tests() { | ||||
Show All 11 Lines |