problem with __dereference_operator_requirement_violation

Richard Andrews richarda@ixla.com.au
Thu Feb 1 20:00:00 GMT 2001


Hi Folks,

I have a container class and an item class which work fine together.

However if I attempt to use std::advance() on an iterator of type
container<item>::iterator then I get a compilation error as below.


item.h: In static member function `static void _STL_ERROR::__dereference_operator_requirement_violation(_Iterator) [with _Iterator = ixla::container<ixla::item>::iterator]':
container.h:XXX:   instantiated from here
..
item.h:XXX: `ixla::item::item(const ixla::item&)' is private
/usr/develop/gcc-20010115/include/g++-v3/bits/concept_checks.h:408: within this context
/usr/develop/gcc-20010115/include/g++-v3/bits/concept_checks.h:408: initializing argument 1 of `void __sink_unused_warning(_Type) [with _Type = ixla::item]'
/usr/develop/gcc-20010115/include/g++-v3/bits/concept_checks.h:408: cannot allocate an object of type `ixla::item'
/usr/develop/gcc-20010115/include/g++-v3/bits/concept_checks.h:408: because the following virtual functions are abstract:
item.h:XXX: 	virtual retType ixla::item::method() const
..
more abstract member error lines


ixla::item is an abstract class and container<item> internally stores
pointers to item objects.

The container<item>::iterator works fine because operator*() only needs to
return item &. So the following code is fine

container<item>::iterator it ( cont1.begin() );
it->doVirtualMember();
//or
(*it).doVirtualMember();


To the question:

Why does __dereference_operator_requirement_violation() require that the
item class be concrete? Shouldn't the parameter be passed by reference?

This is not a libstdc++ container yet it seems that std::advance will only
work with an iterator for a libstdc++ container (or one which satisfies all
their characteristics).

Shouldn't the templated std algorithms work with anything that will provide
the necessary members?

Sorry for the long question. Please answer.

(using CVS2001-01-15 codesourcery build)

Thanks in advance

Rich




More information about the Libstdc++ mailing list