[xsd-users] Re: list construction from std::iterators.
boris at codesynthesis.com
Tue Jun 26 12:58:08 EDT 2007
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;
> // 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():
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!
More information about the xsd-users