[xsd-users] using <algorithm>

Boris Kolpackov boris at codesynthesis.com
Sat Feb 25 08:30:28 EST 2006


Jean-Francois,

Jean-Francois Dube <jf at magnu.polymtl.ca> writes:

> Is there a way to use the standard <algorithm> library with sequence
> iterators?
>
> For intance, I could use the find_if() algorithm on a sequence of books :
>
> find_if ( begin, end, hasISBN( 1234 ) )
>
> In this case, it would emulate the selector mecanism.

There are some parts missing in the iterator implementation in 1.9.0.
I've fixed it on my workspace and put out a patch:

http://codesynthesis.com/~boris/tmp/xsd-1.9.0-algorithm-extras.tar.bz2

Just replace containers.hxx in xsd/cxx/tree with the one in the archive.
This will also appear in the next release.

With this fix, the following example works fine for me:

struct has_isbn
{
  has_isbn (library::isbn v)
      : v_ (v)
  {
  }

  bool
  operator() (library::book const& b) const
  {
    return b.isbn () == v_;
  }

private:
  library::isbn v_;
};

catalog::book::iterator i (
  std::find_if (
    l->book ().begin (), l->book ().end (), has_isbn (679760806)));



Thanks for reporting this!

-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060225/3e80b5ea/attachment.pgp


More information about the xsd-users mailing list