How to check if a template parameter is an iterator type or not?

后端 未结 5 1422
迷失自我
迷失自我 2020-12-17 19:21
template
struct is_iterator
{
    static const bool value = ??? // What to write ???
};

int main()
{
    assert(false == is_iterator::valu         


        
5条回答
  •  Happy的楠姐
    2020-12-17 19:59

    template < class T, class Enabler = void >
    struct is_iterator : public boost::false_type { };
    
    template < class T >
    struct is_iterator< T, typename boost::enable_if_c<
            sizeof(*(*(T*)0)) + sizeof((*(T*)0)++) + sizeof(++(*(T*)0)) +
            sizeof((*(T*)0) == (*(T*)0)) + sizeof((*(T*)0) != (*(T*)0)) +
            sizeof((*(T*)0) = (*(T*)0)) >::type > : public boost::true_type { };
    

提交回复
热议问题