$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r52613 - sandbox/SOC/2009/fusion/mini-fusion
From: mr.chr.schmidt_at_[hidden]
Date: 2009-04-26 16:48:41
Author: cschmidt
Date: 2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
New Revision: 52613
URL: http://svn.boost.org/trac/boost/changeset/52613
Log:
updated the concepts
Added:
   sandbox/SOC/2009/fusion/mini-fusion/categories.hpp   (contents, props changed)
Text files modified: 
   sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp    |    88 ++++++++++++++++++--------------------- 
   sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp |     5 +                                       
   sandbox/SOC/2009/fusion/mini-fusion/test.cpp        |     6 --                                      
   sandbox/SOC/2009/fusion/mini-fusion/vector.hpp      |     3 +                                       
   4 files changed, 47 insertions(+), 55 deletions(-)
Added: sandbox/SOC/2009/fusion/mini-fusion/categories.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/mini-fusion/categories.hpp	2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
@@ -0,0 +1,15 @@
+// Copyright Christopher Schmidt 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+#pragma once
+
+namespace boost{namespace fusion{namespace gsoc{
+	class forward_iterator_category;
+	class bidirectional_iterator_category;
+	class random_access_iterator_category;
+
+	class forward_sequence_category;
+	class bidirectional_sequence_category;
+	class random_access_sequence_category;
+}}}
Modified: sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp	(original)
+++ sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp	2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
@@ -4,82 +4,74 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 #pragma once
 
-#include "convenience.hpp"
-
 #include <concepts>
 
-#include <boost/mpl/int.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/contains.hpp>
+#include <boost/mpl/bool.hpp>
 
-//ConceptGCC does not implement recursive concepts or associated type templates yet, therefore
-//these concepts are preliminary and incomplete.
 namespace boost{namespace fusion{namespace gsoc{
+	//Fusion-iterators and sequences are defined through a set of (meta-)functions rather than their own public interface.
+	//Unfortunately some of these (meta-)functions are not valid for specific valid types (e.g. next is invalid on an end
+	//iterator). We also need arguments for most (meta-)functions, which cannot be provided easily in the context of a concept.
+	//Therefore we ignore these (meta-)functions here.
+
         namespace detail
         {
-		template<class Iterator,class IntegralConstant>
-			typename result_of::advance_c<Iterator,IntegralConstant::value>::type advance_c_test(const Iterator& iterator,IntegralConstant)
-		{
-			return advance_c<0>(iterator);
-		}
+		typedef mpl::vector<forward_iterator_category,bidirectional_iterator_category,random_access_iterator_category> forward_iterator_categories;
+		typedef mpl::vector<bidirectional_iterator_category,random_access_iterator_category> bidirectional_iterator_categories;
+		typedef mpl::vector<random_access_iterator_category> random_access_iterator_categories;
         }
 
-	//Fusion-iterators are defined through a set of (meta-)functions rather than their own public interface.
-	//That means we need to instantiate these functions in our concept with fitting arguments to check if
-	//the specified type models a valid fusion iterator.
-	auto concept ForwardIterator<class Iterator,
-		class OtherIterator=Iterator> :
+	auto concept ForwardIterator<class Iterator> :
                         std::CopyConstructible<Iterator>//, std::HasEqualTo<Iterator,Iterator>, std::HasNotEqualTo<Iterator,Iterator>
         {
-		//The iterators must have the same tag (e.g. vector_iterator_tag), otherwise operations on them wont make any sense!
                 typename tag=typename Iterator::tag;
-		typename otheriterator_tag=typename OtherIterator::tag;
-		requires std::SameType<tag,otheriterator_tag>;
-
-		//TODO: The sequence of the underlying iterators should be the same
-		//The sequence is not publically exposed though.
-
-		//advance_c<0> should work on all iterators.
-		//the computed types of the metafunctions should not exposed publically
-		//therefore the detail prefix
-		typename detail_advance_c_type=typename result_of::advance_c<Iterator,0>::type;
-		//detail_advance_c_type advance_c<0>(const Iterator&); is not valid in a concept!
-		detail_advance_c_type advance_c_test(const Iterator&);
-
-		typename detail_distance_type=typename result_of::distance<Iterator,OtherIterator>::type;
-		//requires boost::mpl::concepts::Integral<detail_distance_type>;
-		detail_distance_type distance(const Iterator&,const OtherIterator&);
-
-		//The following (meta-)functions are only valid for non-end iterators. Instantiating
-		//these functions with end-iterators might fail and therefore end-iterators could not be
-		//accepted by this concept.
-		//What to do? A different concept for non-end iterators?
-
-		//typename detail_next_type=typename result_of::next<Iterator>::type;
-		//detail_next_type next(const Iterator&);
+		typename category=typename Iterator::category;
 
-		//typename detail_deref_type=typename result_of::deref<Iterator>::type;
-		//detail_deref_type deref(const Iterator&);
-
-		//typename detail_value_of_type=typename result_of::value_of<Iterator>::type;
+		//requires std::SameType<mpl::contains<detail::forward_iterator_categories,tag>::type,mpl::true_>; segfaults in ConceptGCC!
+		typename detail_is_valid=typename mpl::contains<detail::forward_iterator_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
         }
 
-	/*auto concept BidirectionalIterator<class Iterator> : ForwardIterator<Iterator>
+	auto concept BidirectionalIterator<class Iterator> : ForwardIterator<Iterator>
         {
+		typename detail_is_valid=typename mpl::contains<detail::bidirectional_iterator_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
         }
 
         auto concept RandomAccessIterator<class Iterator> : BidirectionalIterator<Iterator>
         {
-	}*/
+		typename detail_is_valid=typename mpl::contains<detail::random_access_iterator_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
+	}
 
-	/*auto concept ForwardSequence<class Sequence>
+	namespace detail
         {
+		typedef mpl::vector<forward_sequence_category,bidirectional_sequence_category,random_access_sequence_category> forward_sequence_categories;
+		typedef mpl::vector<bidirectional_sequence_category,random_access_sequence_category> bidirectional_sequence_categories;
+		typedef mpl::vector<random_access_sequence_category> random_access_sequence_categories;
+	}
+
+	auto concept ForwardSequence<class Sequence> :
+		std::CopyConstructible<Sequence>//, std::HasEqualTo<Sequence,Sequence>, std::HasNotEqualTo<Sequence,Sequence>
+	{
+		typename tag=typename Sequence::tag;
+		typename category=typename Sequence::category;
+
+		typename detail_is_valid=typename mpl::contains<detail::forward_sequence_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
         }
 
         auto concept BidirectionalSequence<class Sequence> : ForwardSequence<Sequence>
         {
+		typename detail_is_valid=typename mpl::contains<detail::bidirectional_sequence_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
         }
 
         auto concept RandomAccessSequence<class Sequence> : BidirectionalSequence<Sequence>
         {
+		typename detail_is_valid=typename mpl::contains<detail::random_access_sequence_categories,category>::type;
+		requires std::SameType<detail_is_valid,mpl::true_>;
         }
-	*/
 }}}
Modified: sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp	(original)
+++ sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp	2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
@@ -6,6 +6,9 @@
 
 //TODO: constexpr
 
+#include "categories.hpp"
+#include "concepts.hpp"
+
 #include <type_traits>
 #include <cstddef>
 
@@ -88,7 +91,7 @@
                         };
                 }
 
-		template<class Iterator,int Distance>class advance_c:
+		template<class Iterator,int Distance> class advance_c:
                         public impl::advance_c<typename Iterator::tag>::template apply<Iterator,Distance>
                 {
                 };
Modified: sandbox/SOC/2009/fusion/mini-fusion/test.cpp
==============================================================================
--- sandbox/SOC/2009/fusion/mini-fusion/test.cpp	(original)
+++ sandbox/SOC/2009/fusion/mini-fusion/test.cpp	2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
@@ -44,16 +44,10 @@
         }
 };
 
-template<boost::fusion::gsoc::ForwardIterator ForwardIterator>void forward_iterator_func()
-{
-}
-
 int main()
 {
         namespace gsoc=boost::fusion::gsoc;
 
-	forward_iterator_func<gsoc::result_of::begin<gsoc::vector<>>::type>();
-
         {
                 typedef gsoc::vector<> at;
 
Modified: sandbox/SOC/2009/fusion/mini-fusion/vector.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/mini-fusion/vector.hpp	(original)
+++ sandbox/SOC/2009/fusion/mini-fusion/vector.hpp	2009-04-26 16:48:40 EDT (Sun, 26 Apr 2009)
@@ -4,6 +4,7 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 #pragma once
 
+#include "categories.hpp"
 #include "convenience.hpp"
 
 #include <utility>
@@ -31,6 +32,7 @@
                         friend class result_of::impl::deref<vector_iterator_tag>;
 
                 public:
+			typedef random_access_iterator_category category;
                         typedef vector_iterator_tag tag;
                         typedef mpl::bool_<std::is_const<Vector>::value> is_const;
 
@@ -153,6 +155,7 @@
                 typedef mpl::size_t<sizeof...(Elements)> num_elements;
 
         public:
+		typedef random_access_sequence_category category;
                 typedef vector_tag tag;
 
                 vector()