operator== missing on std::__debug::map<>::iterator
Daniel Krügler
daniel.kruegler@gmail.com
Tue Dec 11 06:36:00 GMT 2012
2012/12/11 Gabriel Dos Reis <gdr@integrable-solutions.net>:
> On Mon, Dec 10, 2012 at 3:42 PM, Daniel Krügler
> <daniel.kruegler@gmail.com> wrote:
>> 2012/12/10 Jonathan Wakely <jwakely.gcc@gmail.com>
>>>
>>> On 10 December 2012 21:29, Marc Glisse wrote:
>>> >
>>> > By the way, would the standard allow those iterators to be final? (not
>>> > suggesting it, just asking, because it doesn't seem forbidden)
>>>
>>> I have a vague recollection of discussing this in the past somewhere
>>> and the consensus was that implementations cannot add 'final' to such
>>> types. But I might be misremembering the discussion.
>>
>> I think that implementation-provided iterator belong to the "gray zone" where
>> declaring them as final would be feasible, see
>>
>> http://cplusplus.github.com/LWG/lwg-closed.html#2113
>>
>> - Daniel
>
> Why should a C++ program care about iterator being final or not?
> (I am not talking about conformance testsuites.)
I have seen such code and written it ;-): If you have to manage a set
of compilers
where at least one has very little sfinae support, a typical way to
check whether
a template argument type satisfies some constraints (such is: "is it
an input iterator?"
or "is it callable with a specific set of arguments") involves a
sub-branch (after having
eliminated non-class types) that ad-hoc derives from the template argument type.
Here a code snippet of this quite popular technique:
struct testers
{
struct Fallback
{
void operator++();
void operator*();
};
template<class U>
static two test1(type_value<void (Fallback::*)(), &U::operator++>*);
template<class>
static one test1(...);
template<class U>
static two test2(type_value<void (Fallback::*)(), &U::operator*>*);
template<class>
static one test2(...);
};
template<class T, bool = ::boost::is_class<T>::value>
struct has : testers
{
struct Derived : T, Fallback {};
static const bool value = sizeof(test1<Derived>(0)) == sizeof(one) &&
sizeof(test2<Derived>(0)) == sizeof(one);
typedef has type;
};
The technique is a C++03 technique but you cannot replace all your previously
valid code when you switch to a C++11 environment.
- Daniel
More information about the Libstdc++
mailing list