diff --git a/include/boost/pending/concept_archetypes.hpp b/include/boost/pending/concept_archetypes.hpp new file mode 100644 index 0000000..65387df --- /dev/null +++ b/include/boost/pending/concept_archetypes.hpp @@ -0,0 +1,278 @@ +// $COPYRIGHT + +#ifndef BOOST_CONCEPT_ARCHETYPES_HPP +#define BOOST_CONCEPT_ARCHETYPES_HPP + +#include + +namespace boost { + + //=========================================================================== + // Basic Archetype Classes + + class dummy_constructor { }; + static dummy_constructor dummy_cons; + + + // A type that models no concept. + class null_archetype { + private: + null_archetype() { } + null_archetype(const null_archetype&) { } + null_archetype& operator=(const null_archetype&) { return *this; } + public: + null_archetype(dummy_constructor) { } + friend void dummy_friend(); // just to avoid warnings + }; + + template + class static_object { + public: + static T& get() { + dummy_constructor d; + static T x(d); + return x; + } + }; + template <> + class static_object { + public: + static bool& get() { + static bool b; + return b; + } + }; + + template + class left_equality_comparable_archetype : public Base { + public: + left_equality_comparable_archetype(dummy_constructor x) + : Base(x) { } + }; + template + bool operator==(const T&, const left_equality_comparable_archetype&) + { return true; } + template + bool operator!=(const T&, const left_equality_comparable_archetype&) + { return true; } + + template + class equality_comparable_archetype : public Base { + public: + equality_comparable_archetype(dummy_constructor x) : Base(x) { } + }; + template + bool operator==(const equality_comparable_archetype&, + const equality_comparable_archetype&) { return true; } + template + bool operator!=(const equality_comparable_archetype&, + const equality_comparable_archetype&) { return true; } + + template + class convertible_to : public Base { + public: + convertible_to(dummy_constructor x) : Base(x) { } + operator const T&() const { return static_object::get(); } + }; + + template + class default_constructible_archetype : public Base { + public: + default_constructible_archetype() : Base(dummy_cons) { } + default_constructible_archetype(dummy_constructor x) : Base(x) { } + }; + + template + class copy_constructible_archetype : public Base { + public: + copy_constructible_archetype() : Base(dummy_cons) { } + copy_constructible_archetype(const copy_constructible_archetype&) + : Base(dummy_cons) { } + copy_constructible_archetype(dummy_constructor x) : Base(x) { } + }; + + template + class assignable_archetype : public Base { + public: + assignable_archetype& operator=(const assignable_archetype&) { + return *this; + } + assignable_archetype(dummy_constructor x) : Base(x) { } + }; + + + //=========================================================================== + // Function Object Archetype Classes + + template + class unary_function_archetype { + public: + const Return& operator()(const Arg&) { + return static_object::get(); + } + }; + + template + class predicate_archetype { + typedef convertible_to Return; + public: + const Return& operator()(const Arg&) { + return static_object::get(); + } + }; + + template + class binary_predicate_archetype { + typedef convertible_to Return; + public: + const Return& operator()(const Arg1&, const Arg2&) { + return static_object::get(); + } + }; + + + //=========================================================================== + // Iterator Archetype Classes + + template + struct input_proxy { + operator const T&() { return static_object::get(); } + }; + template + class trivial_iterator_archetype + { + typedef trivial_iterator_archetype self; + public: +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + typedef T value_type; + typedef void reference; + typedef void pointer; + typedef void difference_type; + typedef void iterator_category; +#endif + trivial_iterator_archetype() { } + self& operator=(const self&) { return *this; } + bool operator==(const self&) const { return true; } + bool operator!=(const self&) const { return true; } + input_proxy operator*() { return input_proxy(); } + }; +} // namespace boost + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +namespace std { + template + struct iterator_traits< boost::trivial_iterator_archetype > + { + typedef T value_type; + }; +} +#endif + +namespace boost { + template + struct input_output_proxy { + input_output_proxy& operator=(const T&) { return *this; } + operator T() { return t; } + T t; + }; + template + class mutable_trivial_iterator_archetype + { + typedef mutable_trivial_iterator_archetype self; + public: +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + typedef T value_type; + typedef void reference; + typedef void pointer; + typedef void difference_type; + typedef void iterator_category; +#endif + mutable_trivial_iterator_archetype() { } + self& operator=(const self&) { return *this; } + bool operator==(const self&) const { return true; } + bool operator!=(const self&) const { return true; } + input_output_proxy operator*() { return input_output_proxy(); } + T x; + }; +} // namespace boost + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +namespace std { + template + struct iterator_traits< boost::mutable_trivial_iterator_archetype > + { + typedef T value_type; + }; +} +#endif + +namespace boost { + + template + class input_iterator_archetype + { + public: + typedef input_iterator_archetype 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; } + reference operator*() { return static_object::get(); } + self& operator++() { return *this; } + self operator++(int) { return *this; } + }; + + struct output_proxy { + template + output_proxy& operator=(const T&) { return *this; } + }; + + class output_iterator_archetype + { + public: + typedef output_iterator_archetype self; + public: + typedef std::output_iterator_tag iterator_category; + typedef output_proxy value_type; + typedef output_proxy reference; + typedef void pointer; + typedef void difference_type; + 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*() { return output_proxy(); } + self& operator++() { return *this; } + self operator++(int) { return *this; } + }; + + template + class forward_iterator_archetype + { + public: + typedef forward_iterator_archetype self; + public: + typedef std::forward_iterator_tag iterator_category; + typedef T value_type; + typedef T& reference; + typedef T* pointer; + typedef void difference_type; + forward_iterator_archetype() { } + self& operator=(const self&) { return *this; } + bool operator==(const self&) const { return true; } + bool operator!=(const self&) const { return true; } + reference operator*() { return static_object::get(); } + self& operator++() { return *this; } + self operator++(int) { return *this; } + }; + + +} // namespace boost + +#endif // BOOST_CONCEPT_ARCHETYPES_H diff --git a/include/boost/pending/concept_checks.hpp b/include/boost/pending/concept_checks.hpp index 57c8a9c..35d8a8e 100644 --- a/include/boost/pending/concept_checks.hpp +++ b/include/boost/pending/concept_checks.hpp @@ -1,28 +1,9 @@ // -//======================================================================= -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek -// -// This file is part of the Generic Graph Component Library -// -// You should have received a copy of the License Agreement for the -// Generic Graph Component Library along with the software; see the -// file LICENSE. If not, contact Office of Research, University of Notre -// Dame, Notre Dame, IN 46556. -// -// Permission to modify the code and to distribute modified code is -// granted, provided the text of this NOTICE is retained, a notice that -// the code was modified is included with the above COPYRIGHT NOTICE and -// with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE -// file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= +// (C) Copyright Jeremy Siek 2000. 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. // #ifndef BOOST_GRAPH_DETAIL_CONCEPT_CHECKS_HPP #define BOOST_GRAPH_DETAIL_CONCEPT_CHECKS_HPP @@ -119,7 +100,7 @@ template void ignore_unused_variable_warning(const T&) { } struct Integer_concept { void constraints() { #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - error_the_type_must_be_an_integer_type(); + error__type_must_be_an_integer_type(); #endif } }; @@ -133,6 +114,21 @@ template void ignore_unused_variable_warning(const T&) { } // etc. #endif + template + struct SignedInteger_concept { + void constraints() { +#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + error__type_must_be_a_signed_integer_type(); +#endif + } + }; +#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template <> struct SignedInteger_concept { void constraints() {} }; + template <> struct SignedInteger_concept { void constraints() {} }; + template <> struct SignedInteger_concept { void constraints() {} }; + // etc. +#endif + //=========================================================================== // Basic Concepts @@ -146,6 +142,9 @@ template void ignore_unused_variable_warning(const T&) { } X x; }; + // Issue, the SGI STL version of Assignable is + // different from the C++ standard definition of Assignable. + // This follows the C++ standard version. template struct Assignable_concept { @@ -153,16 +152,12 @@ template void ignore_unused_variable_warning(const T&) { } #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = a; // require assignment operator #endif - TT c(a); // require copy constructor const_constraints(a); - ignore_unused_variable_warning(c); } void const_constraints(const TT& b) { #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL a = b; // const required for argument to assignment #endif - TT c(b); // const required for argument to copy constructor - ignore_unused_variable_warning(c); } TT a; }; @@ -213,7 +208,18 @@ template void ignore_unused_variable_warning(const T&) { } // the error message appears. template void require_boolean_return(B) { REQUIRE(B, Boolean); } TT a, b; - bool r; + }; + + template + struct LeftEqualityComparable_concept + { + void constraints() { + require_boolean_return(b == a); + require_boolean_return(b != a); + } + template void require_boolean_return(B) { REQUIRE(B, Boolean); } + XX a; + YY b; }; template @@ -267,6 +273,7 @@ template void ignore_unused_variable_warning(const T&) { } // require iterator_traits typedef's #ifndef BOOST_NO_STD_ITERATOR_TRAITS typedef typename std::iterator_traits::difference_type D; + REQUIRE(D, SignedInteger); typedef typename std::iterator_traits::reference R; typedef typename std::iterator_traits::pointer P; typedef typename std::iterator_traits::iterator_category C;