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 <vector> | |
#include <boost/type_traits/integral_constant.hpp> | |
#include <cstdio> | |
template <class T> | |
struct is_stdvector: boost::false_type {}; | |
template <class T, class Allocator> | |
struct is_stdvector<std::vector<T, Allocator> >: boost::true_type | |
{}; | |
int main() | |
{ | |
printf("int=%s\n", is_stdvector<int>::value ? "true" : "false"); | |
printf("vector<int>=%s\n", is_stdvector<std::vector<int>>::value ? "true" : "false"); | |
printf("vector<char*>=%s\n", is_stdvector<std::vector<char*>>::value ? "true" : "false"); | |
return 0; | |
} |
kuyu@ub16:~/dkuyu/Dropbox/practice/cpp/polukhin/ch04/implement_type_trait$ g++ -std=c++11 -I/home/kuyu/dkuyu/bin/boost_1_60_0 1.cpp && ./a.out
int=false
vector<int>=true
vector<char*>=true
No comments:
Post a Comment