how to detect if a type is an iterator or const_iterator

前端 未结 5 465
北荒
北荒 2020-12-31 07:24

I\'m wondering, if there is a way to check at compile time whether a type T of some iterator type is a const_iterator, or not. Is there some difference in the types that ite

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 07:59

    C++11

    template())>    
    constexpr bool  
    is_const_iterator() {   
            return  ! std::is_assignable <
                    decltype( *std::declval() ),
                    T   
            >::value;
    }
    

提交回复
热议问题