|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52584 - in sandbox/SOC/2009/fusion: mini-fusion workaround/conceptgcc
From: mr.chr.schmidt_at_[hidden]
Date: 2009-04-24 19:12:26
Author: cschmidt
Date: 2009-04-24 19:12:25 EDT (Fri, 24 Apr 2009)
New Revision: 52584
URL: http://svn.boost.org/trac/boost/changeset/52584
Log:
Improved mini-fusion to test conceptgcc again
Text files modified:
sandbox/SOC/2009/fusion/mini-fusion/convenience.hpp | 2
sandbox/SOC/2009/fusion/mini-fusion/test.cpp | 95 +++++++++++++++++++++------------------
sandbox/SOC/2009/fusion/mini-fusion/vector.hpp | 7 ++
sandbox/SOC/2009/fusion/workaround/conceptgcc/utility | 12 +++++
4 files changed, 70 insertions(+), 46 deletions(-)
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-24 19:12:25 EDT (Fri, 24 Apr 2009)
@@ -327,7 +327,7 @@
};
}
- template<std::size_t Index,class Container>typename result_of::at_c<Container,Index>::type at_c(const Container& container)
+ template<std::size_t Index,class Container>typename result_of::at_c<const Container,Index>::type at_c(const Container& container)
{
return result_of::at_c<const 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:12:25 EDT (Fri, 24 Apr 2009)
@@ -48,56 +48,63 @@
namespace gsoc=boost::fusion::gsoc;
{
+ typedef gsoc::vector<> at;
+
+ {
+ 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,"");
+ }
+
+ {
+ at a;
+
+ 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));
+ }
+ }
+
+ {
+ typedef gsoc::vector<long long,float,char> bt;
+
+ {
+ 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,"");
+
+ static_assert(std::is_same<value_of<begin<bt>::type>::type,long long>::value,"");
+ }
+
{
- typedef gsoc::vector<> at;
+ bt b(0xDEADBEEF,1337.0f,42);
- {
- 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,"");
- }
-
- {
- at a;
-
- 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));
- }
+ 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));
+
+ assert(deref(begin(b))==0xDEADBEEF);
+ at_c<0>(b)=0xBEEFDEEF;
+ assert(at_c<0>(b)==0xBEEFDEEF);
}
{
- typedef gsoc::vector<long long,float,char> bt;
+ const bt b(0xDEADBEEF,1337.0f,42);
- {
- 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,"");
-
- static_assert(std::is_same<value_of<begin<bt>::type>::type,long long>::value,"");
- }
-
- {
- bt b(0xDEADBEEF,1337.0f,42);
-
- 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));
-
- assert(deref(begin(b))==0xDEADBEEF);
- at_c<0>(b)=0xBEEFDEEF;
- assert(at_c<0>(b)==0xBEEFDEEF);
- }
+ using namespace gsoc;
+ assert(deref(begin(b))==0xDEADBEEF);
+ //at_c<0>(b)=0xBEEFDEEF;
+ assert(at_c<0>(b)==0xBEEFDEEF);
}
}
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-24 19:12:25 EDT (Fri, 24 Apr 2009)
@@ -31,6 +31,7 @@
public:
typedef vector_iterator_tag tag;
+ typedef mpl::bool_<std::is_const<Vector>::value> is_const;
private:
typedef Vector sequence;
@@ -315,8 +316,12 @@
public:
template<class Iterator>class apply
{
+ private:
+ typedef typename result_of::value_of<Iterator>::type value_type;
public:
- typedef typename std::add_reference<typename result_of::value_of<Iterator>::type>::type type;
+ typedef typename std::add_reference<
+ typename std::conditional<Iterator::is_const::value,typename std::add_const<value_type>::type,value_type>::type
+ >::type type;
private:
template<std::size_t Index,class VectorImpl>static typename std::enable_if<!Index,type>::type impl(VectorImpl& impl)
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:12:25 EDT (Fri, 24 Apr 2009)
@@ -20,6 +20,18 @@
typedef Type type;
};
+ template<bool, class TrueType, class>class conditional
+ {
+ public:
+ typedef TrueType type;
+ };
+
+ template<class TrueType, class FalseType>class conditional<false, TrueType, FalseType>
+ {
+ public:
+ typedef FalseType type;
+ };
+
namespace detail
{
//20.3.2...
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