diff --git a/concept_check_test.cpp b/concept_check_test.cpp index 32f0dd5..aa1ac8d 100644 --- a/concept_check_test.cpp +++ b/concept_check_test.cpp @@ -137,6 +137,11 @@ main() typedef output_iterator_archetype Iter; function_requires< OutputIteratorConcept >(); } + { + typedef input_output_iterator_archetype Iter; + function_requires< InputIteratorConcept >(); + function_requires< OutputIteratorConcept >(); + } { typedef forward_iterator_archetype > Iter; function_requires< ForwardIteratorConcept >(); diff --git a/include/boost/concept_archetype.hpp b/include/boost/concept_archetype.hpp index 5eb39dc..d137cc0 100644 --- a/include/boost/concept_archetype.hpp +++ b/include/boost/concept_archetype.hpp @@ -406,19 +406,21 @@ namespace boost { template class input_iterator_archetype { - public: + private: typedef input_iterator_archetype self; public: typedef std::input_iterator_tag iterator_category; typedef T value_type; - typedef const T& reference; + struct reference { + operator value_type() { return static_object::get(); } + }; typedef const T* pointer; typedef std::ptrdiff_t difference_type; input_iterator_archetype() { } self& operator=(const self&) { return *this; } bool operator==(const self&) const { return true; } bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } + reference operator*() const { return reference(); } self& operator++() { return *this; } self operator++(int) { return *this; } }; @@ -451,6 +453,30 @@ namespace boost { output_iterator_archetype() { } }; + template + class input_output_iterator_archetype + { + private: + typedef input_output_iterator_archetype self; + struct in_out_tag : public std::input_iterator_tag, public std::output_iterator_tag { }; + public: + typedef in_out_tag iterator_category; + typedef T value_type; + struct reference { + reference& operator=(const T&) { return *this; } + operator value_type() { return static_object::get(); } + }; + typedef const T* pointer; + typedef std::ptrdiff_t difference_type; + input_output_iterator_archetype() { } + self& operator=(const self&) { return *this; } + bool operator==(const self&) const { return true; } + bool operator!=(const self&) const { return true; } + reference operator*() const { return reference(); } + self& operator++() { return *this; } + self operator++(int) { return *this; } + }; + template class forward_iterator_archetype {