aui::tuple_visitor
Provides an easy way to iterate over a parameter pack.
Header: | #include <AUI/Traits/parameter_pack.h> |
CMake: | aui_link(my_target PUBLIC aui::core) |
Detailed Description
without |
with |
template<typename Arg, typename... Args> void helperFunc(Arg&& arg, Args&&... args) {
// do something with arg
std::cout << std::forward<Arg>(arg) << std::endl;
if constexpr (sizeof...(args) > 0) {
helperFunc(std::forward<Args>(args)...); // continue iteration
}
}
template<typename... Args> void yourFunc(Args&&... args) {
helperFunc(std::forward<Args>(args)...);
}
|
template<typename... Args> void yourFunc(Args&&... args) {
aui::parameter_pack::for_each([](auto&& i) {
// do something with arg
std::cout << i << " ";
}, std::forward<Args>(args)...);
}
|