Add comments for every method in field set helpers
This commit is contained in:
parent
32f3fccf17
commit
7619b0c339
1 changed files with 37 additions and 5 deletions
|
@ -25,10 +25,16 @@ constexpr auto GetType(R(T::* ptr)) -> R;
|
|||
// return kUtils.With(&SomeStruct::field2, std::forward<Self>(self), std::move(field2)); // With field2
|
||||
// }
|
||||
// };
|
||||
template <typename T, typename... Fs>
|
||||
export template <typename T, typename... Fs>
|
||||
struct FieldsDescription {
|
||||
utempl::Tuple<Fs...> tuple;
|
||||
|
||||
utempl::Tuple<Fs...> tuple; /*!< tuple for field ptrs */
|
||||
/* Method accepting field index, self and new value for field and returns object with new field value
|
||||
*
|
||||
* \param I field index for object T
|
||||
* \param self old object
|
||||
* \param value new value for field
|
||||
* \return T with new field value and values from self
|
||||
*/
|
||||
template <std::size_t I, typename Self, typename Value>
|
||||
constexpr auto With(Self&& self, Value&& value) const
|
||||
requires([] {
|
||||
|
@ -50,6 +56,13 @@ struct FieldsDescription {
|
|||
} | utempl::kSeq<sizeof...(Fs)>;
|
||||
};
|
||||
|
||||
/* Method accepting field pointer, self and new value for field and returns object with new field value
|
||||
*
|
||||
* \param ptr field ptr for object T
|
||||
* \param self old object
|
||||
* \param value new value for field
|
||||
* \return T with new field value and values from self
|
||||
*/
|
||||
template <typename Self, typename Value, typename Type>
|
||||
constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const
|
||||
requires std::is_constructible_v<Type, decltype(value)>
|
||||
|
@ -72,10 +85,15 @@ consteval auto CreateFieldsDescriptionHelper(Fs&&... fs) -> FieldsDescription<T,
|
|||
return {.tuple = {std::forward<Fs>(fs)...}};
|
||||
};
|
||||
|
||||
/* Method accepting field ptrs and returns FieldsDescription
|
||||
*
|
||||
* \param ptrs field ptrs
|
||||
* \return FieldsDescription with T and ptrs
|
||||
*/
|
||||
export template <typename T, typename... Rs>
|
||||
consteval auto CreateFieldsDescription(Rs(T::*... ptr)) {
|
||||
consteval auto CreateFieldsDescription(Rs(T::*... ptrs)) {
|
||||
return [&](auto... is) {
|
||||
return CreateFieldsDescriptionHelper<T>(ptr...);
|
||||
return CreateFieldsDescriptionHelper<T>(ptrs...);
|
||||
} | utempl::kSeq<sizeof...(Rs)>;
|
||||
};
|
||||
|
||||
|
@ -96,6 +114,13 @@ consteval auto CreateFieldsDescription(Rs(T::*... ptr)) {
|
|||
// };
|
||||
|
||||
export struct FieldSetHelper {
|
||||
/* Method accepting field index, self and new value for field and returns object with new field value
|
||||
*
|
||||
* \param I field index for object T
|
||||
* \param self old object
|
||||
* \param value new value for field
|
||||
* \return T with new field value and values from self
|
||||
*/
|
||||
template <std::size_t I, typename Self, typename Value>
|
||||
static constexpr auto With(Self&& self, Value&& value)
|
||||
requires([] {
|
||||
|
@ -117,6 +142,13 @@ export struct FieldSetHelper {
|
|||
} | utempl::kSeq<boost::pfr::tuple_size_v<T>>;
|
||||
};
|
||||
|
||||
/* Method accepting field name, self and new value for field and returns object with new field value
|
||||
*
|
||||
* \param FieldName field name for object T
|
||||
* \param self old object
|
||||
* \param value new value for field
|
||||
* \return T with new field value and values from self
|
||||
*/
|
||||
template <utempl::ConstexprString FieldName, typename Self, typename Value>
|
||||
static constexpr auto With(Self&& self, Value&& value) -> decltype(With<[] {
|
||||
auto names = boost::pfr::names_as_array<std::decay_t<Self>>();
|
||||
|
|
Loading…
Reference in a new issue