Skip to content

Instantly share code, notes, and snippets.

@Xipiryon
Last active February 5, 2018 14:37
Show Gist options
  • Save Xipiryon/a3a14384eabda03baa15a216491fe755 to your computer and use it in GitHub Desktop.
Save Xipiryon/a3a14384eabda03baa15a216491fe755 to your computer and use it in GitHub Desktop.
Partial Specialization Syntax
template<class T>
struct Foo;
// Pointer to Function
// ************************************
template<class RetType, class...Args>
struct Foo<RetType(*name)(Args...)> {};
// Pointer to Class Member Function
// ************************************
template<class RetType, class Class, class...Args>
struct Foo<RetType(Class::*name)(Args...)> {};
// Pointer to Class Member
// ************************************
template<class Type, class Class>
struct Foo<Type(Class::*name)> {};
// Fixed Size Array
// ************************************
template<class Type, size_t N>
struct Foo<Type[N]> {};
// Pointer to Fixed Size Array
// ************************************
template<class Type, size_t N>
struct Foo<Type (*name)[N]> {};
// Reference to Fixed Size Array
// ************************************
template<class Type, size_t N>
struct Foo<Type (&name)[N]> {};
// Pointer to Class Member: Fixed Size Array
// ************************************
template<class Class, class Type, size_t N>
struct Foo<Type (Class::*name)[N]> {};
// A template template class
// ************************************
template<template <class> Base, class T>
struct Foo<Base<T>> {};
// Any templated class with variadic number of template parameters
// ************************************
template<template class <...> Base, class...Ts>
struct Foo<Base<Ts...>> {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment