c++ - How to know if a type is a specialization of std::vector? -


i've been on problem morning no result whatsoever. basically, need simple metaprogramming thing allows me branch different specializations if parameter passed kind of std::vector or not.

some kind of is_base_of templates.

does such thing exist ?

in c++11 can in more generic way:

#include <type_traits> #include <iostream>  template<typename test, template<typename...> class ref> struct is_specialization : std::false_type {};  template<template<typename...> class ref, typename... args> struct is_specialization<ref<args...>, ref>: std::true_type {};   int main() {     typedef std::vector<int> vec;     typedef int not_vec;     std::cout << is_specialization<vec, std::vector>::value << is_specialization<not_vec, std::vector>::value;      typedef std::list<int> lst;     typedef int not_lst;     std::cout << is_specialization<lst, std::list>::value << is_specialization<not_lst, std::list>::value; } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -