Is there a simple way to add the current index of the arg
As in include it in the lambda call so I don't need to use index++
template <typename... Args>
void Function(Args... args) {
std::size_t size = sizeof...(Args);
std::size_t index = 0;
auto process = [] <typename Arg> (Arg && arg) {
index++;
if (typeid(arg) == typeid(char*) || typeid(arg) == typeid(const char*)) {
std::size_t sValueSize = strlen(arg) + 1;
}
};
(process(std::forward<Args>(args)), ...);
}
You can use a helper function along with a
std::index_sequencewhich will let you unpack both the args and indices and pass them to your lambda in the fold expression:Live Demo