Skip to content

Commit 1741324

Browse files
committed
Fix reflect_value contract.
Fixes llvm#136.
1 parent 82ebef0 commit 1741324

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

libcxx/include/experimental/meta

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ template <reflection_range R = initializer_list<info>>
8080
8181
// reflect expression results
8282
template <typename T>
83-
consteval auto reflect_value(T) -> info;
83+
consteval auto reflect_value(const T&) -> info;
8484
template <typename T>
8585
consteval auto reflect_object(T &) -> info;
8686
template <typename T>
@@ -979,8 +979,8 @@ public:
979979
}
980980

981981
consteval access_context via(info new_naming_class) const {
982-
if (!is_class_type(new_naming_class) || !is_complete_type(new_naming_class))
983-
throw "naming class must be a reflection of a complete class type";
982+
if (!is_class_type(new_naming_class))
983+
throw "naming class must be a reflection of a class type";
984984

985985
return access_context{d_scope, new_naming_class};
986986
}
@@ -1433,11 +1433,9 @@ consteval auto is_user_declared(info r) -> bool {
14331433
template <typename T>
14341434
requires (!is_reference_v<T> &&
14351435
__metafunction(detail::__metafn_is_structural_type, ^^T))
1436-
consteval auto reflect_value(T r) -> info {
1437-
constexpr info Ty = type_of(^^r);
1438-
1439-
return __metafunction(detail::__metafn_reflect_result, Ty,
1440-
static_cast<typename [:Ty:] &&>(r));
1436+
consteval auto reflect_value(const T &r) -> info {
1437+
return __metafunction(detail::__metafn_reflect_result, ^^T,
1438+
static_cast<T>(r));
14411439
}
14421440

14431441
// Returns a reflection of the object designated by the provided argument.

libcxx/test/std/experimental/reflection/to-and-from-values.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ static_assert(type_of(std::meta::reflect_value(ConstVar)) == ^^int);
5454
static_assert([:std::meta::reflect_value(ConstexprVar):] == ConstexprVar);
5555
static_assert(type_of(std::meta::reflect_value(ConstexprVar)) == ^^int);
5656

57-
static_assert([:std::meta::reflect_value(fn):] == &fn);
58-
static_assert(type_of(std::meta::reflect_value(fn)) == ^^void(*)());
57+
static_assert([:std::meta::reflect_value(&fn):] == &fn);
58+
static_assert(type_of(std::meta::reflect_value(&fn)) == ^^void(*)());
5959

6060
static_assert([:std::meta::reflect_value(&Cls::k):] == &Cls::k);
6161
static_assert(type_of(std::meta::reflect_value(&Cls::k)) == ^^int (Cls::*));

0 commit comments

Comments
 (0)