I have two and a half closely related questions. Given an STL iterator-type passed as a template parameter:
- How to determine whether the type corresponds to a const- or non-const iterator?
- Alternatively to 1., how to impose (using
enable_ifs for instance) that this type corresponds to a non-const iterator? How to obtain the const- version of the iterator from the non-const one (and vice versa)?[ Note: answered in this post; not surprisingly, you can't. ]
Where does this question come from:
I wrote a small class to facilitate arithmetic/relational/algebraic operations on vectors (by vector I mean 1d fixed-size data, not the STL vectors). Instead of imposing a specific data container, I've defined an interface and derived several possible containers that are basically "wrapping" various ways of storing data. One of these containers is a wrapper for STL-iterators, and I'm having some troubles with it.
std::is_const<decltype(*it)>. - BoBTFishconst_iteratorandconst iteratorare two different things. Try this: pastebin.com/kKQEQthj - Jonathan Hdecltype(*it)when I posted my last comment.. You would be right too with this I guess :) - Jonathan H