|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52583 - in sandbox/SOC/2009/fusion: . fusion mini-fusion workaround/conceptgcc
From: mr.chr.schmidt_at_[hidden]
Date: 2009-04-24 19:02:33
Author: cschmidt
Date: 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
New Revision: 52583
URL: http://svn.boost.org/trac/boost/changeset/52583
Log:
Improved mini-fusion to test conceptgcc
Added:
sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp (contents, props changed)
sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp (contents, props changed)
sandbox/SOC/2009/fusion/mini-fusion/vector.hpp (contents, props changed)
Removed:
sandbox/SOC/2009/fusion/fusion/
Text files modified:
sandbox/SOC/2009/fusion/build.bat | 10
sandbox/SOC/2009/fusion/mini-fusion/test.cpp | 326 +++++++++------------------------------
sandbox/SOC/2009/fusion/workaround/conceptgcc/utility | 12 +
3 files changed, 96 insertions(+), 252 deletions(-)
Modified: sandbox/SOC/2009/fusion/build.bat
==============================================================================
--- sandbox/SOC/2009/fusion/build.bat (original)
+++ sandbox/SOC/2009/fusion/build.bat 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -17,20 +17,20 @@
call :gcc
) else (
if "%1" == "msvc" (
- call :msvc
+ call :msvc
) else (
if "%1" == "" (
- call :conceptgcc
+ call :conceptgcc
) else (
echo Unknown toolset '%1'
- goto :eof
+ goto :eof
)
)
)
)
rem compile...
-z:\projekte\cl_link_frontend\tools\bjam --toolset=%TOOLSET% mini-fusion
+z:\projekte\cl_link_frontend\tools\bjam --toolset=%TOOLSET% mini-fusion %2 %3 %4 %5 %6 %7 %8 %9
goto :eof
:conceptgcc
@@ -53,4 +53,4 @@
:msvc
call "%VS90COMNTOOLS%..\..\VC\vcvarsall" x86
set TOOLSET=msvc
-goto :eof
\ No newline at end of file
+goto :eof
Added: sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/mini-fusion/concepts.hpp 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -0,0 +1,55 @@
+// 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
+
+//Based on these concepts the convenience functions are implemented!
+
+/*auto concept MetaFunction<class Type>
+{
+ typename type;
+}
+
+auto concept ForwardIterator<class Type>
+{
+ MetaFunction get_next;
+}
+
+auto concept BidirectionalIterator<class Type>
+{
+ requires ForwardIterator<Type>;
+
+ MetaFunction get_prior;
+}
+
+auto concept RandomAccessIterator<class Type>
+{
+ MetaFunction advance;
+ MetaFunction get_distance;
+}
+
+auto concept FusionSequence<class Type>
+{
+ class get_begin;
+ //MetaFunction get_begin;
+ //requires MetaFunction<get_next>;
+ MetaFunction get_end;
+}
+
+auto concept ForwardSequence<class Type>
+{
+ requires FusionSequence<Type>;
+
+ MetaFunction get_size;
+}
+
+auto concept BidirectionalSequence<class Type>
+{
+ requires ForwardSequence<Type>;
+}
+
+auto concept RandomAccessSequence<class Type>
+{
+ requires FusionSequence<Type>;
+}*/
Added: sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -0,0 +1,340 @@
+// 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
+
+//TODO: constexpr!!!
+
+#include <type_traits>
+#include <cstddef>
+
+#include <boost/mpl/bool.hpp>
+
+namespace boost{namespace fusion{namespace gsoc{
+ namespace detail
+ {
+ template<class Arg>class always_false
+ {
+ public:
+ typedef boost::mpl::false_ type;
+ };
+ }
+
+ //begin
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class begin
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported sequence");
+ };
+ }
+
+ template<class Sequence> class begin:
+ public impl::begin<typename Sequence::tag>::template apply<Sequence>
+ {
+ };
+ }
+ template<class Sequence> typename result_of::begin<typename std::remove_reference<Sequence>::type>::type begin(Sequence&& sequence)
+ {
+ return result_of::begin<typename std::remove_reference<Sequence>::type>::call(std::forward<Sequence>(sequence));
+ }
+ template<class Sequence> typename result_of::begin<const Sequence>::type begin(const Sequence& sequence)
+ {
+ return result_of::begin<const Sequence>::call(sequence);
+ }
+
+ //end
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class end
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported sequence");
+ };
+ }
+
+ template<class Sequence>class end:
+ public impl::end<typename Sequence::tag>::template apply<Sequence>
+ {
+ };
+ }
+ template<class Sequence> typename result_of::end<typename std::remove_reference<Sequence>::type>::type end(Sequence&& sequence)
+ {
+ return result_of::end<typename std::remove_reference<Sequence>::type>::call(std::forward<Sequence>(sequence));
+ }
+ template<class Sequence> typename result_of::end<const Sequence>::type end(const Sequence& sequence)
+ {
+ return result_of::end<const Sequence>::call(sequence);
+ }
+
+ //advance_c
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class advance_c
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported iterator");
+ };
+ }
+
+ template<class Iterator,int Distance>class advance_c:
+ public impl::advance_c<typename Iterator::tag>::template apply<Iterator,Distance>
+ {
+ };
+ }
+ template<int Distance,class Iterator> typename result_of::advance_c<Iterator,Distance>::type advance_c(const Iterator& iterator)
+ {
+ return result_of::advance_c<Iterator,Distance>::call(iterator);
+ }
+
+ //distance
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class distance
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported iterator");
+ };
+ }
+
+ template<class IteratorA,class IteratorB>class distance:
+ public impl::distance<typename IteratorA::tag>::template apply<IteratorA,IteratorB>
+ {
+ //!!!
+ static_assert(std::is_same<typename IteratorA::tag,typename IteratorB::tag>::value,"Different iterator types specified");
+ };
+ }
+ template<class IteratorA,class IteratorB> typename result_of::distance<IteratorA,IteratorB>::type
+ distance(const IteratorA& iteratora,const IteratorB& iteratorb)
+ {
+ return typename result_of::distance<IteratorA,IteratorB>::type();
+ }
+
+ //next
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class next
+ {
+ public:
+ template<class Iterator>class apply
+ {
+ public:
+ typedef typename result_of::advance_c<Iterator,1>::type type;
+
+ static type call(const Iterator& iterator)
+ {
+ return gsoc::advance_c<1>(iterator);
+ }
+ };
+ };
+ }
+
+ template<class Iterator>class next:
+ public impl::next<typename Iterator::tag>::template apply<Iterator>
+ {
+ };
+ }
+ template<class Iterator> typename result_of::next<Iterator>::type next(const Iterator& iterator)
+ {
+ return result_of::next<Iterator>::call(iterator);
+ }
+
+ //prior
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class prior
+ {
+ public:
+ template<class Iterator>class apply
+ {
+ public:
+ typedef typename result_of::advance_c<Iterator,-1>::type type;
+
+ static type call(const Iterator& iterator)
+ {
+ return gsoc::advance_c<-1>(iterator);
+ }
+ };
+ };
+ }
+
+ template<class Iterator>class prior:
+ public impl::prior<typename Iterator::tag>::template apply<Iterator>
+ {
+ };
+ }
+ template<class Iterator> typename result_of::prior<Iterator>::type prior(const Iterator& iterator)
+ {
+ return result_of::prior<Iterator>::call(iterator);
+ }
+
+ //equal_to
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class equal_to
+ {
+ public:
+ template<class IteratorA,class IteratorB>class apply
+ {
+ public:
+ typedef mpl::bool_<std::is_same<
+ typename std::add_const<IteratorA>::type,
+ typename std::add_const<IteratorB>::type>::value> type;
+ };
+ };
+ }
+
+ template<class IteratorA,class IteratorB>class equal_to:
+ public impl::equal_to<typename IteratorA::tag>::template apply<IteratorA,IteratorB>
+ {
+ static_assert(std::is_same<typename IteratorA::tag,typename IteratorB::tag>::value,"Different iterator types specified");
+ };
+ }
+ template<class IteratorA,class IteratorB> typename result_of::equal_to<IteratorA,IteratorB>::type
+ equal_to(const IteratorA& iteratora,const IteratorB& iteratorb)
+ {
+ return typename result_of::equal_to<IteratorA,IteratorB>::type();
+ }
+
+ //size
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class size
+ {
+ public:
+ template<class Sequence>class apply:
+ public result_of::distance<typename result_of::begin<Sequence>::type,typename result_of::end<Sequence>::type>
+ {
+ };
+ };
+ }
+
+ template<class Sequence>class size :
+ public impl::size<typename Sequence::tag>::template apply<Sequence>
+ {
+ };
+ }
+ template<class Sequence> typename result_of::size<Sequence>::type size(const Sequence&)
+ {
+ return typename result_of::size<Sequence>::type();
+ }
+
+ //empty
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class empty
+ {
+ public:
+ template<class Sequence> class apply
+ {
+ public:
+ typedef mpl::bool_<result_of::equal_to<
+ typename result_of::begin<Sequence>::type,
+ typename result_of::end<Sequence>::type>::type::value> type;
+ };
+ };
+ }
+
+ template<class Sequence>class empty:
+ public impl::empty<typename Sequence::tag>::template apply<Sequence>
+ {
+ };
+ }
+ template<class Sequence> typename result_of::empty<Sequence>::type empty(const Sequence&)
+ {
+ return typename result_of::empty<Sequence>::type();
+ }
+
+ //value_of
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class value_of
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported iterator");
+ };
+ }
+
+ template<class Iterator>class value_of:
+ public impl::value_of<typename Iterator::tag>::template apply<Iterator>
+ {
+ };
+ }
+
+ //deref
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class deref
+ {
+ static_assert(detail::always_false<Tag>::type::value, "Unsupported iterator");
+ };
+ }
+
+ template<class Iterator>class deref:
+ public impl::deref<typename Iterator::tag>::template apply<Iterator>
+ {
+ };
+ }
+ template<class Iterator>typename result_of::deref<Iterator>::type deref(const Iterator& iterator)
+ {
+ return result_of::deref<Iterator>::call(iterator);
+ }
+
+ //at_c
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<class Tag>class at_c
+ {
+ public:
+ template<class Container,std::size_t Index>class apply
+ {
+ public:
+ typedef typename result_of::deref<
+ typename result_of::advance_c<typename result_of::begin<Container>::type,Index>::type>::type type;
+
+ static type call(Container& container)
+ {
+ return gsoc::deref(gsoc::advance_c<Index>(gsoc::begin(container)));
+ }
+ };
+ };
+ }
+
+ template<class Container,std::size_t Index>class at_c:
+ public impl::at_c<typename Container::tag>::template apply<Container,Index>
+ {
+ };
+ }
+
+ template<std::size_t Index,class Container>typename result_of::at_c<Container,Index>::type at_c(const Container& container)
+ {
+ return result_of::at_c<const Container,Index>::call(container);
+ }
+
+ template<std::size_t Index,class Container>typename result_of::at_c<Container,Index>::type at_c(Container& container)
+ {
+ return result_of::at_c<Container,Index>::call(container);
+ }
+}}}
+
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-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -3,288 +3,122 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include <utility>
-#include <concepts>
+//!!!These are my local testfiles - therefore hardly any comments, "#pragma once" in headers and #include ""!!!
-#include <boost/mpl/size_t.hpp>
-#include <boost/mpl/bool.hpp>
+#include "vector.hpp"
+#include "convenience.hpp"
-namespace boost{namespace fusion{namespace gsoc{
+#include <cassert>
- namespace detail
+class copyable
+{
+public:
+ copyable()
{
- template<class... Elements> class vector_impl;
- template<> class vector_impl<>{};
-
- template<class Head,class...Other>class vector_impl<Head,Other...> :
- public vector_impl<Other...>
- {
- template<class...> friend class vector_impl;
+ }
+ copyable(const copyable&)
+ {
+ }
+ copyable& operator=(const copyable&)
+ {
+ return *this;
+ }
+};
- private:
- typedef vector_impl<Other...> base;
+class moveable
+{
+private:
+ moveable(const moveable&);
- Head _element;
+public:
+ moveable()
+ {
+ }
+ moveable(moveable&&)
+ {
+ }
+ moveable& operator=(moveable&&)
+ {
+ return *this;
+ }
+};
- public:
- vector_impl()
- {
- }
+int main()
+{
+ namespace gsoc=boost::fusion::gsoc;
- vector_impl(const vector_impl& other_impl):
- base(other_impl),
- _element(other_impl._element)
- {
- }
+ {
+ {
+ typedef gsoc::vector<> at;
- vector_impl(vector_impl&& other_impl):
- base(std::move(other_impl)),
- _element(std::move(other_impl._element))
{
+ using namespace gsoc::result_of;
+ static_assert(equal_to<advance_c<begin<at>::type,0>::type,end<at>::type>::type::value,"");
+ static_assert(!distance<begin<at>::type,end<at>::type>::type::value,"");
+ static_assert(!size<at>::type::value,"");
+ static_assert(empty<at>::type::value,"");
}
- template<class OtherHead,class... OtherElements>vector_impl(const OtherHead& other_head,const OtherElements&... other_elements):
- base(other_elements...),
- _element(other_head)
{
- }
+ at a;
- template<class OtherHead,class... OtherElements>vector_impl(OtherHead&& other_head,OtherElements&&... other_elements):
- base(std::forward<OtherElements>(other_elements)...),
- _element(std::forward<OtherHead>(other_head))
- {
+ using namespace gsoc;
+ assert(equal_to(advance_c<0>(begin(a)),end(a)));
+ assert(!distance(begin(a),end(a)));
+ assert(!size(a));
+ assert(empty(a));
}
+ }
- template<class OtherHead,class... OtherElements>vector_impl(const vector_impl<OtherHead,OtherElements...>& other_impl):
- base(other_impl),
- _element(other_impl._element)
- {
- }
+ {
+ typedef gsoc::vector<long long,float,char> bt;
- template<class OtherHead,class... OtherElements>vector_impl(vector_impl<OtherHead,OtherElements...>&& other_impl):
- base(std::move(other_impl)),
- _element(std::move(other_impl._element))
{
- }
+ using namespace gsoc::result_of;
+ static_assert(equal_to<advance_c<begin<bt>::type,3>::type,end<bt>::type>::type::value,"");
+ static_assert(distance<begin<bt>::type,end<bt>::type>::type::value==3,"");
+ static_assert(distance<next<begin<bt>::type>::type,prior<end<bt>::type>::type>::type::value==1,"");
+ static_assert(size<bt>::type::value==3,"");
+ static_assert(!empty<bt>::type::value,"");
- void operator=(const vector_impl& other_impl)
- {
- _element=other_impl._element;
- static_cast<base&>(*this)=other_impl;
+ static_assert(std::is_same<value_of<begin<bt>::type>::type,long long>::value,"");
}
- void operator=(vector_impl&& other_impl)
{
- _element=std::move(other_impl._element);
- static_cast<base&>(*this)=std::move(other_impl);
- }
+ bt b(0xDEADBEEF,1337.0f,42);
- template<class OtherHead,class... OtherElements>void operator=(const vector_impl<OtherHead,OtherElements...>& other_impl)
- {
- _element=other_impl._element;
- static_cast<base&>(*this)=other_impl;
- }
+ using namespace gsoc;
+ assert(equal_to(advance_c<3>(begin(b)),end(b)));
+ assert(distance(begin(b),end(b))==3);
+ assert(distance(next(begin(b)),prior(end(b)))==1);
+ assert(size(b)==3);
+ assert(!empty(b));
- template<class OtherHead,class... OtherElements>void operator=(vector_impl<OtherHead,OtherElements...>&& other_impl)
- {
- _element=std::move(other_impl._element);
- static_cast<base&>(*this)=std::move(other_impl);
+ assert(deref(begin(b))==0xDEADBEEF);
+ at_c<0>(b)=0xBEEFDEEF;
+ assert(at_c<0>(b)==0xBEEFDEEF);
}
- };
- }
-
- template<class... Elements>class vector:
- public detail::vector_impl<Elements...>
- {
- private:
- typedef detail::vector_impl<Elements...> base;
-
- public:
- vector()
- {
- }
-
- vector(const vector& other_vector):
- base(other_vector)
- {
- }
-
- vector(vector&& other_vector):
- base(std::move(other_vector))
- {
- }
-
- template<class... OtherElements> vector(const vector<OtherElements...>& other_vector):
- base(other_vector)
- {
- }
-
- template<class... OtherElements> vector(vector<OtherElements...>&& other_vector):
- base(std::move(other_vector))
- {
- }
-
- template<class... OtherElements> explicit vector(const OtherElements&... other_elements):
- base(std::forward<OtherElements>(other_elements)...)
- {
- }
-
- template<class... OtherElements> explicit vector(OtherElements&&... other_elements):
- base(std::forward<OtherElements>(other_elements)...)
- {
- }
-
- /*template<class OtherSequence> vector(OtherSequence&& other_sequence)
- {
- }
-
- template<class OtherSequence> vector(const OtherSequence& other_sequence)
- {
- }*/
-
- vector& operator=(const vector& other_vector)
- {
- static_cast<base&>(*this)=other_vector;
- return *this;
- }
-
- vector& operator=(vector&& other_vector)
- {
- static_cast<base&>(*this)=std::move(other_vector);
- return *this;
- }
- };
-
- template<class Vector, std::size_t Index> class vector_iterator
- {
- public:
- typedef mpl::size_t<Index> index;
- typedef Vector vector;
-
- private:
- Vector& _vector;
-
- public:
- vector_iterator(Vector& vector):
- _vector(vector)
- {
}
- };
-
- namespace result_of
- {
- template<class Sequence>class size;
- template<class... Elements>class size<vector<Elements...>>
- {
- public:
- typedef mpl::size_t<sizeof...(Elements)> type;
- };
-
- template<class Sequence>class empty
- {
- public:
- typedef mpl::bool_<!size<Sequence>::type::value> type;
- };
-
- template<class Sequence>class begin;
- template<class... Elements>class begin<vector<Elements...>>
- {
- public:
- typedef vector_iterator<vector<Elements...>,0> type;
- };
-
- template<class Sequence>class end;
- template<class... Elements>class end<vector<Elements...>>
- {
- public:
- typedef vector_iterator<vector<Elements...>,size<vector<Elements...>>::type::value> type;
- };
-
- template<class Sequence>class next;
- template<class Vector,std::size_type Index>class next<vector_iterator<vector,Index>>
- {
- public:
- typedef vector_iterator<Vector,Index+1> type;
- };
}
- template<class Sequence> typename result_of::size<Sequence>::type size(const Sequence&)
{
- return typename result_of::size<Sequence>::type();
+ gsoc::vector<moveable,moveable> c;
+ gsoc::vector<moveable,moveable> d;
+ c=std::move(d);
}
- template<class Sequence> typename result_of::empty<Sequence>::type empty(const Sequence&)
{
- return typename result_of::empty<Sequence>::type();
+ gsoc::vector<copyable,copyable> c;
+ gsoc::vector<copyable,copyable> d;
+ c=d;
+ c=std::move(d);
}
- template<class Sequence> typename result_of::begin<Sequence>::type begin(Sequence& sequence)
- {
- return result_of::begin<Sequence>(sequence);
- }
-
- template<class Sequence> typename result_of::begin<Sequence const>::type begin(const Sequence& sequence)
- {
- return result_of::begin<const Sequence>(sequence);
- }
-
- template<class Sequence> typename result_of::end<Sequence>::type end(Sequence& sequence)
- {
- return result_of::end<Sequence>(sequence);
- }
-
- template<class Sequence> typename result_of::end<Sequence const>::type end(const Sequence& sequence)
- {
- return result_of::end<const Sequence>(sequence);
- }
-}}}
-
-class copyable
-{
-//private:
- //copyable(copyable&&);
-
-public:
- copyable()
- {
- }
- copyable(const copyable&)
- {
- }
-};
-
-class moveable
-{
-private:
- moveable(const moveable&);
-
-public:
- moveable()
{
+ gsoc::vector<moveable,copyable> c;
+ gsoc::vector<moveable,copyable> d;
+ c=std::move(d);
}
- moveable(moveable&&)
- {
- }
-};
-
-int main()
-{
- namespace gsoc=boost::fusion::gsoc;
- using namespace std;
-
- gsoc::vector<int,float,char> a;
- gsoc::vector<int,float,char> b(0,0,0);
-
- a=b;
- b=move(a);
-
- gsoc::vector<moveable,copyable> c;
- moveable ma;
- copyable ca;
- gsoc::vector<moveable,copyable> d(move(ma),move(ca));
-
- //c=c;
- //d=move(d);
return 0;
}
Added: sandbox/SOC/2009/fusion/mini-fusion/vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/mini-fusion/vector.hpp 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -0,0 +1,351 @@
+// 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
+
+#include "convenience.hpp"
+
+#include <utility>
+#include <type_traits>
+#include <cstddef>
+
+#include <boost/mpl/size_t.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+
+namespace boost{namespace fusion{namespace gsoc{
+ class vector_tag;
+
+ namespace detail
+ {
+ class vector_iterator_tag;
+ template<class Vector,std::size_t Index> class vector_iterator
+ {
+ friend class result_of::impl::end<vector_tag>;
+ friend class result_of::impl::begin<vector_tag>;
+ friend class result_of::impl::advance_c<vector_iterator_tag>;
+ friend class result_of::impl::distance<vector_iterator_tag>;
+ friend class result_of::impl::value_of<vector_iterator_tag>;
+ friend class result_of::impl::deref<vector_iterator_tag>;
+
+ public:
+ typedef vector_iterator_tag tag;
+
+ private:
+ typedef Vector sequence;
+ typedef mpl::size_t<Index> index;
+
+ Vector& _vector;
+
+ vector_iterator(Vector& vector):
+ _vector(vector)
+ {
+ }
+ };
+
+ template<class... Elements> class vector_impl;
+ template<> class vector_impl<>{};
+
+ template<class Head,class...Other>class vector_impl<Head,Other...> :
+ public vector_impl<Other...>
+ {
+ public:
+ friend class result_of::impl::deref<detail::vector_iterator_tag>;
+
+ typedef vector_impl<Other...> base;
+ typedef Head head_type;
+
+ private:
+ Head _element;
+
+ public:
+ vector_impl()
+ {
+ }
+
+ vector_impl(const vector_impl& other_impl):
+ base(static_cast<const base&>(other_impl)),
+ _element(other_impl._element)
+ {
+ }
+
+ vector_impl(vector_impl&& other_impl):
+ base(std::move(static_cast<base&>(other_impl))),
+ _element(std::move(other_impl._element))
+ {
+ }
+
+ template<class OtherHead,class... OtherElements>vector_impl(const OtherHead& other_head,const OtherElements&... other_elements):
+ base(other_elements...),
+ _element(other_head)
+ {
+ }
+
+ template<class OtherHead,class... OtherElements>vector_impl(OtherHead&& other_head,OtherElements&&... other_elements):
+ base(std::forward<OtherElements>(other_elements)...),
+ _element(std::forward<OtherHead>(other_head))
+ {
+ }
+
+ template<class OtherHead,class... OtherElements>vector_impl(const vector_impl<OtherHead,OtherElements...>& other_impl):
+ base(static_cast<const typename vector_impl<OtherHead,OtherElements...>::base&>(other_impl)),
+ _element(other_impl._element)
+ {
+ }
+
+ template<class OtherHead,class... OtherElements>vector_impl(vector_impl<OtherHead,OtherElements...>&& other_impl):
+ base(std::move(static_cast<typename vector_impl<OtherHead,OtherElements...>::base&>(other_impl))),
+ _element(std::move(other_impl._element))
+ {
+ }
+
+ void operator=(const vector_impl& other_impl)
+ {
+ _element=other_impl._element;
+ static_cast<base&>(*this)=static_cast<const base&>(other_impl);
+ }
+
+ void operator=(vector_impl&& other_impl)
+ {
+ _element=std::move(other_impl._element);
+ static_cast<base&>(*this)=std::move(static_cast<base&>(other_impl));
+ }
+
+ template<class OtherHead,class... OtherElements>void operator=(const vector_impl<OtherHead,OtherElements...>& other_impl)
+ {
+ _element=other_impl._element;
+ static_cast<base&>(*this)=static_cast<const typename vector_impl<OtherHead,OtherElements...>::base&>(other_impl);
+ }
+
+ template<class OtherHead,class... OtherElements>void operator=(vector_impl<OtherHead,OtherElements...>&& other_impl)
+ {
+ _element=std::move(other_impl._element);
+ static_cast<base&>(*this)=std::move(static_cast<typename vector_impl<OtherHead,OtherElements...>::base&>(other_impl));
+ }
+ };
+ }
+
+ template<class... Elements>class vector:
+ private detail::vector_impl<Elements...>
+ {
+ friend class result_of::impl::end<vector_tag>;
+ friend class result_of::impl::begin<vector_tag>;
+ friend class result_of::impl::value_of<detail::vector_iterator_tag>;
+ friend class result_of::impl::deref<detail::vector_iterator_tag>;
+
+ private:
+ typedef detail::vector_impl<Elements...> base;
+ typedef mpl::size_t<sizeof...(Elements)> num_elements;
+
+ public:
+ typedef vector_tag tag;
+
+ vector()
+ {
+ }
+
+ vector(const vector& other_vector):
+ base(other_vector)
+ {
+ }
+
+ vector(vector&& other_vector):
+ base(std::move(other_vector))
+ {
+ }
+
+ template<class... OtherElements> vector(const vector<OtherElements...>& other_vector):
+ base(other_vector)
+ {
+ }
+
+ template<class... OtherElements> vector(vector<OtherElements...>&& other_vector):
+ base(std::move(other_vector))
+ {
+ }
+
+ template<class... OtherElements> explicit vector(const OtherElements&... other_elements):
+ base(std::forward<OtherElements>(other_elements)...)
+ {
+ }
+
+ template<class... OtherElements> explicit vector(OtherElements&&... other_elements):
+ base(std::forward<OtherElements>(other_elements)...)
+ {
+ }
+
+ /*template<class OtherSequence> vector(OtherSequence&& other_sequence)
+ {
+ }
+
+ template<class OtherSequence> vector(const OtherSequence& other_sequence)
+ {
+ }*/
+
+ vector& operator=(const vector& other_vector)
+ {
+ static_cast<base&>(*this)=other_vector;
+ return *this;
+ }
+
+ vector& operator=(vector&& other_vector)
+ {
+ static_cast<base&>(*this)=std::move(other_vector);
+ return *this;
+ }
+ };
+
+ //begin
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class begin<vector_tag>
+ {
+ public:
+ template<class Vector>class apply
+ {
+ public:
+ typedef gsoc::detail::vector_iterator<Vector,0> type;
+
+ static type call(Vector& vector)
+ {
+ return type(vector);
+ }
+ };
+ };
+ }
+ }
+
+ //end
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class end<vector_tag>
+ {
+ public:
+ template<class Vector> class apply
+ {
+ public:
+ typedef gsoc::detail::vector_iterator<Vector,Vector::num_elements::value> type;
+
+ static type call(Vector& vector)
+ {
+ return type(vector);
+ }
+ };
+ };
+ }
+ }
+
+ //advance_c
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class advance_c<gsoc::detail::vector_iterator_tag>
+ {
+ public:
+ template<class Iterator,int Distance>class apply
+ {
+ public:
+ typedef gsoc::detail::vector_iterator<typename Iterator::sequence,Iterator::index::value+Distance> type;
+
+ static type call(const Iterator& iterator)
+ {
+ return type(iterator._vector);
+ }
+ };
+ };
+ }
+ }
+
+ //distance
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class distance<gsoc::detail::vector_iterator_tag>
+ {
+ public:
+ template<class IteratorA,class IteratorB>class apply
+ {
+ public:
+ typedef mpl::size_t<IteratorB::index::value-IteratorA::index::value> type;
+ };
+ };
+ }
+ }
+
+ //value_of
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class value_of<gsoc::detail::vector_iterator_tag>
+ {
+ public:
+ template<class Iterator>class apply
+ {
+ private:
+ template<class VectorImpl,std::size_t Counter>class impl
+ {
+ public:
+ typedef typename mpl::eval_if_c<!Counter,
+ mpl::identity<typename VectorImpl::head_type>,
+ impl<typename VectorImpl::base,Counter-1> >::type type;
+ };
+
+ public:
+ typedef typename impl<typename Iterator::sequence::base,Iterator::index::value>::type type;
+ };
+ };
+ }
+ }
+
+ //deref
+ namespace result_of
+ {
+ namespace impl
+ {
+ template<>class deref<gsoc::detail::vector_iterator_tag>
+ {
+ public:
+ template<class Iterator>class apply
+ {
+ public:
+ typedef typename std::add_reference<typename result_of::value_of<Iterator>::type>::type type;
+
+ private:
+ template<std::size_t Index,class VectorImpl>static typename std::enable_if<!Index,type>::type impl(VectorImpl& impl)
+ {
+ return impl._element;
+ }
+
+ template<std::size_t Index,class VectorImpl>static typename std::enable_if<Index,type>::type impl(VectorImpl& impl)
+ {
+ return impl<Index-1>(static_cast<typename VectorImpl::base&>(impl));
+ }
+
+ template<std::size_t Index,class VectorImpl>static typename std::enable_if<!Index,type>::type impl(const VectorImpl& impl)
+ {
+ return impl._element;
+ }
+
+ template<std::size_t Index,class VectorImpl>static typename std::enable_if<Index,type>::type impl(const VectorImpl& impl)
+ {
+ return impl<Index-1>(static_cast<const typename VectorImpl::base&>(impl));
+ }
+
+ public:
+ static type call(const Iterator& iterator)
+ {
+ return impl<Iterator::index::value>(iterator._vector);
+ }
+ };
+ };
+ }
+ }
+}}}
Modified: sandbox/SOC/2009/fusion/workaround/conceptgcc/utility
==============================================================================
--- sandbox/SOC/2009/fusion/workaround/conceptgcc/utility (original)
+++ sandbox/SOC/2009/fusion/workaround/conceptgcc/utility 2009-04-24 19:02:31 EDT (Fri, 24 Apr 2009)
@@ -10,6 +10,16 @@
namespace std
{
+ template<bool, class>class enable_if
+ {
+ };
+
+ template<class Type>class enable_if<true, Type>
+ {
+ public:
+ typedef Type type;
+ };
+
namespace detail
{
//20.3.2...
@@ -35,4 +45,4 @@
a = move(b);
b = move(temp);
}
-}
\ No newline at end of file
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk