Created
September 20, 2018 10:43
-
-
Save FinalTheory/c26f46e0a01f86fca274f2f321e115a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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