Skip to content

Commit 53b3b70

Browse files
committed
Rename field_type_at to field_value_type_at
The alias strips cv from the deduced field type, producing a value type suitable as a function parameter or local variable. The old name read as "the field's type" — misleading, since callers cannot use it to inspect the original field's const-ness. Rename to field_value_type_at(_t) so the name matches what the alias actually yields. No behavioural change. Two call sites in Settings.hpp updated; nothing else used the alias.
1 parent 0eb58cb commit 53b3b70

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

include/rfl/Settings.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ T settings_with_replaced(
5454
template <class T, StringLiteral Name>
5555
T settings_with_replaced_by_name(
5656
const T& _obj,
57-
field_type_at_t<T, field_index_by_name_v<T, Name>> _value) {
57+
field_value_type_at_t<T, field_index_by_name_v<T, Name>> _value) {
5858
constexpr std::size_t I = field_index_by_name_v<T, Name>;
5959
static_assert(I != static_cast<std::size_t>(-1),
6060
"No field with the given name exists in T.");
@@ -90,7 +90,7 @@ T settings_with_replaced_by_name(
9090
*this, std::move(_value)); \
9191
} \
9292
template <::rfl::internal::StringLiteral Name> \
93-
Derived with(::rfl::internal::field_type_at_t< \
93+
Derived with(::rfl::internal::field_value_type_at_t< \
9494
Derived, \
9595
::rfl::internal::field_index_by_name_v<Derived, Name>> \
9696
_value) const { \

include/rfl/internal/field_index_by_name.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ inline constexpr std::size_t field_index_by_name_v =
3838
field_index_by_name_impl<T, Name>(
3939
std::make_index_sequence<num_fields<T>>{});
4040

41-
/// Helper: extracts the value type the i-th fake-object pointer points to.
41+
/// Helper: extracts the cv-stripped value type of the i-th field of T,
42+
/// suitable as a function parameter or local variable type. Use this when
43+
/// you need to declare an object of the field's type; do not use it to
44+
/// inspect const-ness of the original field declaration (cv is removed).
4245
template <class T, std::size_t I>
43-
struct field_type_at {
46+
struct field_value_type_at {
4447
using type = std::remove_cv_t<std::remove_pointer_t<
4548
decltype(get_ith_field_from_fake_object<T, static_cast<int>(I)>())>>;
4649
};
@@ -54,12 +57,12 @@ struct unresolved_field_type {};
5457
/// that a failing field_index_by_name_v lookup does not trip an out-of-range
5558
/// instantiation before the caller's static_assert can fire.
5659
template <class T>
57-
struct field_type_at<T, static_cast<std::size_t>(-1)> {
60+
struct field_value_type_at<T, static_cast<std::size_t>(-1)> {
5861
using type = unresolved_field_type;
5962
};
6063

6164
template <class T, std::size_t I>
62-
using field_type_at_t = typename field_type_at<T, I>::type;
65+
using field_value_type_at_t = typename field_value_type_at<T, I>::type;
6366

6467
} // namespace rfl::internal
6568

0 commit comments

Comments
 (0)