자료/내자료

mpl::is_vector

쑥갓 2009. 2. 17. 19:51
template<typename T>
struct is_vector_impl
{
enum { value = false };
};

template<typename T>
struct is_vector_impl< std::vector<T> >
{
enum { value = true };
};

template<typename T>
struct is_vector
{
enum { value = is_vector_impl< boost::remove_volatile< boost::remove_const< boost::remove_reference<T>::type >::type >::type >::value };
};

BOOST_STATIC_ASSERT( (is_vector<int>::value == false) );
BOOST_STATIC_ASSERT( (is_vector< std::vector<int> >::value == true) );
BOOST_STATIC_ASSERT( (is_vector< const std::vector<int> >::value == true) );
BOOST_STATIC_ASSERT( (is_vector< std::vector<int>& >::value == true) );
BOOST_STATIC_ASSERT( (is_vector< const std::vector<int>& >::value == true) );

레이옷 블로그에 댓글 달고 있다가 자꾸 글자들을 먹어버려서 여기에 포스팅-_-;