Skip to content

Instantly share code, notes, and snippets.

@jharmer95
Created November 2, 2020 23:42
Show Gist options
  • Save jharmer95/974ebbf0c78deaff08aac51670b7aab7 to your computer and use it in GitHub Desktop.
Save jharmer95/974ebbf0c78deaff08aac51670b7aab7 to your computer and use it in GitHub Desktop.
Iterating through parameter pack TYPES with a lambda
#include <iostream>
#include <type_traits>
template<typename T>
void printStuff1()
{
if constexpr(std::is_pointer_v<T>)
{
std::cout << "POINTER\n";
}
else
{
std::cout << "NOT\n";
}
}
template<typename... Args>
void printStuff()
{
[](...){}((printStuff1<Args>(), 0)...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment