diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp index 0685803..81fd580 100644 --- a/include/boost/iterator/iterator_archetypes.hpp +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -149,12 +149,23 @@ namespace detail template struct archetype; }; + // Constructor argument for those iterators that + // are not default constructible + struct ctor_arg {}; + template struct traversal_archetype_ : mpl::aux::msvc_eti_base< typename traversal_archetype_impl::template archetype >::type - {}; + { + traversal_archetype_() {} + traversal_archetype_(ctor_arg arg) + : mpl::aux::msvc_eti_base< + typename traversal_archetype_impl::template archetype + >::type(arg) + {} + }; template <> struct traversal_archetype_impl @@ -162,6 +173,8 @@ namespace detail template struct archetype { + explicit archetype(ctor_arg) {} + struct bogus { }; // This use to be void, but that causes trouble for iterator_facade. Need more research. -JGS typedef bogus difference_type; @@ -178,6 +191,9 @@ namespace detail : public equality_comparable< traversal_archetype_ >, public traversal_archetype_ { + explicit archetype(ctor_arg arg) + : traversal_archetype_(arg) + {} }; }; @@ -198,6 +214,9 @@ namespace detail struct archetype : public traversal_archetype_ { + archetype() + : traversal_archetype_(ctor_arg()) + {} typedef std::ptrdiff_t difference_type; }; }; diff --git a/test/Jamfile b/test/Jamfile index 32f34e5..38399b1 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -36,6 +36,7 @@ test-suite iterator [ run iterator_adaptor_cc.cpp ] [ run iterator_adaptor_test.cpp ] [ compile iterator_archetype_cc.cpp ] + [ compile-fail iterator_archetype_default_ctor.cpp ] [ run transform_iterator_test.cpp ] [ run indirect_iterator_test.cpp ] [ compile indirect_iterator_member_types.cpp ] diff --git a/test/iterator_archetype_default_ctor.cpp b/test/iterator_archetype_default_ctor.cpp new file mode 100755 index 0000000..fd10b35 --- /dev/null +++ b/test/iterator_archetype_default_ctor.cpp @@ -0,0 +1,22 @@ +// +// Copyright Thomas Witt 2004. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// +#include + + +int main() +{ + typedef boost::iterator_archetype< + int + , boost::iterator_archetypes::readable_iterator_t + , boost::single_pass_traversal_tag + > iter; + + // single_pass_traversal iterators are not required to be + // default constructible + iter it; +}