Skip to content

Commit 484e25a

Browse files
Added some documentation to FoldType and FoldMembers
Signed-off-by: Christian Parpart <[email protected]>
1 parent 49be6a1 commit 484e25a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/reflection-cpp/reflection.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ constexpr void template_for(F&& f)
639639
}(std::make_integer_sequence<t, E - B> {});
640640
}
641641

642+
/// Folds over the members of a type
643+
///
644+
/// @param initialValue The initial value to fold with
645+
/// @param callable The callable to fold with. The parameters are the member name,
646+
/// the member's default value and the current result of the fold.
647+
///
648+
/// @return The result of the fold
642649
template <typename Object, typename Callable, typename ResultType>
643650
constexpr ResultType FoldType(ResultType initialValue, Callable const& callable)
644651
{
@@ -712,6 +719,14 @@ void CallOnMembers(Object& object, Callable&& callable)
712719
[&]<auto I>() { callable(Reflection::MemberNameOf<I, Object>, std::get<I>(Reflection::ToTuple(object))); });
713720
}
714721

722+
/// Folds over the members of an object
723+
///
724+
/// @param object The object to fold over
725+
/// @param initialValue The initial value to fold with
726+
/// @param callable The callable to fold with. The parameters are the member name,
727+
/// the member value and the current result of the fold.
728+
///
729+
/// @return The result of the fold
715730
template <typename Object, typename Callable, typename ResultType>
716731
constexpr ResultType FoldMembers(Object const& object, ResultType initialValue, Callable const& callable)
717732
{

0 commit comments

Comments
 (0)