I am getting an error when trying to add std::iterator_traits for a templated member struct - i.e. I have an iterator class which is a member of a templated outer class:
namespace Toolbox {
template <typename CharType>
class substring_container_adapter
{
public:
struct iterator // : public std::iterator<std::forward_iterator_tag, const CharType *> C++ 17 is very upset at this approach!
{
// iterator constructor
iterator(const CharType * pszPosition, const CharType * pszDelimeters)
Later, I try to add a partial specialization for iterator traits to std because apparently inheriting from std::iterator is deprecated (even though that - or boost::iterator_adaptor<> makes perfect sense and actually works in this and other contexts)...
// define iterator traits for our custom iterators
namespace std
{
template <typename CharType>
struct iterator_traits<class Toolbox::substring_container_adapter<CharType>::iterator>
{
using iterator_category = forward_iterator_tag;
using value_type = CharType;
};
}
However, VC++ 2017 version 15.7.3 (C++ 17 enabled for this project) complains:
error C2764: 'CharType': template parameter not used or deducible in partial specialization 'std::iterator_traits::iterator>'
Why not?
I suspect that this is !@#$ annoying limitation due to trying to partially specialize a member struct instead of a templated struct outside of substring_container_adapter<>?