@@ -837,7 +837,7 @@ struct TypeList
837837// / methods. Importantly can be instatiated from a TypeList and implements a
838838// / similar ::foreach interface
839839// / @warning Some member methods here run on actual instances of types in the
840- // / list. As such, it's unlikely that they can alwasy be resolved at compile
840+ // / list. As such, it's unlikely that they can always be resolved at compile
841841// / time (unlike methods in TypeList). Compilers are notriously bad at
842842// / automatically inlining recursive/nested template instations (without fine
843843// / tuning inline options to the frontend) so the public API of this class is
@@ -855,6 +855,7 @@ struct TupleList
855855 TupleList () = default ;
856856 TupleList (Ts&&... args) : mTuple (std::forward<Ts>(args)...) {}
857857
858+ constexpr auto size () { return std::tuple_size_v<TupleT>; }
858859 constexpr TupleT& tuple () { return mTuple ; }
859860 constexpr TupleT& tuple () const { return mTuple ; }
860861
@@ -886,7 +887,7 @@ struct TupleList
886887 // / calls op(std::get<I>(mTuple)) when pred(I) returns true, then exits,
887888 // / where I = [0,Size). Does not support returning a value.
888889 // / @note This is mainly useful to avoid the overhead of calling std::get<I>
889- // / on every element when only a single element needs processing.
890+ // / on every element when only a single unknown element needs processing.
890891 // /
891892 // / @param pred Predicate to run on each index, should return true/false
892893 // / @param op Function to run on the first element that satisfies pred
@@ -897,9 +898,9 @@ struct TupleList
897898 // / }
898899 // / {
899900 // / Types::AsTupleList tuple(Int32(1), float(3.3), std::string("foo"));
900- // / // prints '3.3'
901+ // / bool runtimeFlags[tuple.size()] = { .... } // some runtime flags
901902 // / tuple.foreach(
902- // / [](auto Idx) { return ( Idx == 1) ; },
903+ // / [& ](auto Idx) { return runtimeFlags[ Idx] ; },
903904 // / [](auto value) { std::cout << value << std::endl; }
904905 // / );
905906 // / }
@@ -958,6 +959,7 @@ struct TupleList<>
958959
959960 TupleList () = default ;
960961
962+ constexpr auto size () { return std::tuple_size_v<TupleT>; }
961963 inline TupleT& tuple () { return mTuple ; }
962964 inline const TupleT& tuple () const { return mTuple ; }
963965
0 commit comments