Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ public:
_Move_from(_That);
}

template <class _ValueType, enable_if_t<conjunction_v<negation<is_same<decay_t<_ValueType>, any>>,
negation<_Is_specialization<decay_t<_ValueType>, in_place_type_t>>,
is_copy_constructible<decay_t<_ValueType>>>,
int> = 0>
template <class _ValueType,
enable_if_t<!is_same_v<decay_t<_ValueType>, any> && !_Is_specialization_v<decay_t<_ValueType>, in_place_type_t>,
int> = 0, // Separate these conditions into two `enable_if_t`s to avoid meta-recursion.
// See LLVM-176877 and GH-6109. N5032 [temp.deduct.general]/7 guarantees:
// "The substitution proceeds in lexical order and stops when
// a condition that causes deduction to fail is encountered."
enable_if_t<is_copy_constructible_v<decay_t<_ValueType>>, int> = 0>
Comment thread
StephanTLavavej marked this conversation as resolved.
any(_ValueType&& _Value) { // initialize with _Value
_Emplace<decay_t<_ValueType>>(_STD forward<_ValueType>(_Value));
}
Expand Down
3 changes: 0 additions & 3 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1112,9 +1112,6 @@ std/input.output/file.streams/fstreams/filebuf.virtuals/xsputn.pass.cpp:1 FAIL
std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp:0 FAIL
std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp:1 FAIL

# Not analyzed. Clang error: no member named 'value' in 'std::is_copy_constructible<ConvertibleFromAndToAny>'
std/utilities/any/any.class/any.cons/value.pass.cpp:2 FAIL

# Not analyzed. Assertion failed: globalMemCounter.checkOutstandingNewLessThanOrEqual(1)
std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp FAIL
std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp FAIL
Expand Down
22 changes: 21 additions & 1 deletion tests/std/tests/P0220R1_any/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ int run_test()

#include <any>
#include <cassert>
#include <type_traits>

#include "any_helpers.h"
#include "count_new.h"
Expand Down Expand Up @@ -1160,15 +1161,34 @@ void test_sfinae_constraints() {
}
}

// https://llvm.org/PR176877
// Avoid constraint meta-recursion for a type both convertible from and to std::any.
template <class T, bool = std::is_copy_constructible<T>::value>
void test_default_template_argument_is_copy_constructible(T) {}

template <class T, bool = std::is_copy_constructible_v<T>>
void test_default_template_argument_is_copy_constructible_v(T) {}

void test_no_constraint_recursion() {
struct ConvertibleFromAndToAny {
ConvertibleFromAndToAny(std::any) {}
};

ConvertibleFromAndToAny src = std::any{};
test_default_template_argument_is_copy_constructible(src);
test_default_template_argument_is_copy_constructible_v(src);
}

int run_test() {
test_copy_move_value<small>();
test_copy_move_value<large>();
test_copy_value_throws<small_throws_on_copy>();
test_copy_value_throws<large_throws_on_copy>();
test_move_value_throws();
test_sfinae_constraints();
test_no_constraint_recursion();

return 0;
return 0;
}
} // namespace ctor::value
// -- END: test/std/utilities/any/any.class/any.cons/value.pass.cpp
Comment thread
StephanTLavavej marked this conversation as resolved.
Expand Down