[xsd-users] Re: list construction from std::iterators.

Boris Kolpackov boris at codesynthesis.com
Tue Jun 26 12:58:08 EDT 2007


Hi David,

david.r.moss at selex-comms.com <david.r.moss at selex-comms.com> writes:


> The sequence<X> base class seems to have the required interface but not
> the list class that derives from it.

Actually it is the generated type that inherits from list that does not
provide the necessary constructors. I've added this to my TODO list.


> // Setup some input as a vector.
> vector<string> v;
> {
>   v.push_back("one");
>   v.push_back("two");
> }
>
> // Standard vector construction from iterators -- ok.
> vector<string> y( v.begin(), v.end() );
>
> // list-type construction -- not ok; no valid constructor.
> string_list_t nl( v.begin(), v.end() );

The workaround would be to use assign():

string_list_t nl;
nl.assign (v.begin(), v.end());


> // Especially useful where an object wants the data on construction!
> object_t o( string_list_t( v.begin(), v.end() ) );

The workaround here is actually faster than the original (less copying):

object_t o (string_list_t ());
o.someList ().assign (v.begin(), v.end());


Thanks for reporting this!

-boris




More information about the xsd-users mailing list