From 1dbbc54e4b705bfefe821ce24a93b03e40f9b5d1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 18 Jan 2004 16:21:14 +0000 Subject: [PATCH] merged from trunk [SVN r21801] --- include/boost/concept_archetype.hpp | 61 +++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/include/boost/concept_archetype.hpp b/include/boost/concept_archetype.hpp index 5eb39dc..4b0cc11 100644 --- a/include/boost/concept_archetype.hpp +++ b/include/boost/concept_archetype.hpp @@ -52,12 +52,13 @@ namespace boost { // is really quite innocent. The name of this class needs to be // changed. template - class static_object { + class static_object + { public: - static T& get() { - static char d[sizeof(T)]; - return *reinterpret_cast(d); - } + static T& get() + { + return *reinterpret_cast(0); + } }; template > @@ -406,15 +407,35 @@ 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; + struct reference { + operator value_type() { return static_object::get(); } + }; + typedef const T* pointer; + typedef std::ptrdiff_t difference_type; + 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 input_iterator_archetype_no_proxy + { + private: + typedef input_iterator_archetype_no_proxy self; public: typedef std::input_iterator_tag iterator_category; typedef T value_type; typedef const T& reference; 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; } @@ -423,7 +444,7 @@ namespace boost { self operator++(int) { return *this; } }; - template + template struct output_proxy { output_proxy& operator=(const T&) { return *this; } }; @@ -451,6 +472,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 {