Skip to content

Instantly share code, notes, and snippets.

@FinalTheory
Created September 20, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FinalTheory/c26f46e0a01f86fca274f2f321e115a6 to your computer and use it in GitHub Desktop.
Save FinalTheory/c26f46e0a01f86fca274f2f321e115a6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <type_traits>
template<typename ... Args>
struct get_size;
template<>
struct get_size<> {
static constexpr int size = 0;
};
template<typename T, typename ... Args>
struct get_size<T, Args...> {
static constexpr int size = sizeof(T) + get_size<Args...>::size;
};
template<typename>
struct get_param_size;
template<typename Ret, typename ... Types>
struct get_param_size<Ret(Types ...)> {
static constexpr int size = get_size<Types...>::size;
};
int func(int a, int arr[4]) {
}
int main() {
std::cout << get_param_size<decltype(func)>::size << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment