|
Boost Users : |
Subject: [Boost-users] [fusion][concept] sequence_base
From: Pieter Op de Beeck (podb.visys_at_[hidden])
Date: 2009-05-13 12:48:07
Hi all.
I'm having difficulty understanding why the code listed below is not
compiling (at least not on my box, gcc-4.3.2 / boost 1.38). (the code
has been stripped and simplified for demonstration).
Context:
I have an interface and a model providing an implementation of this
interface. I use a concept to make sure
that the model provides a member function "foo" of a specific
signature (whether doind it this way is useful or not, is not the
point).
In the example below, the member function "foo" should accept one
parameter. This parameter should be of type
"boost::fusion::sequence_base<SequenceT> const&".
Except, when compiling the compiler informs me: invalid use of incomplete type
struct boost::fusion::extension::begin_impl<boost::fusion::non_fusion_tag>::apply<const
boost::fusion::sequence_base<boost::fusion::list<int, int, int,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >
Without the concept check in the interface class this compiles fine.
Appreciating all your comments on this.
Regards,
Pieter.
======================main.cpp=================================
#include <boost/concept/usage.hpp>
#include <boost/concept/requires.hpp>
#include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/container/generation.hpp>
// simplified concept that requires from the model a member function
'foo' taking in a fusion:sequence_base
template<class Model, typename SequenceT>
struct concept
{
template <void (Model::*) (boost::fusion::sequence_base<SequenceT>
const&) const>
void model_requires_foo();
BOOST_CONCEPT_USAGE(concept)
{
model_requires_foo<&Model::foo>();
}
};
// an interface which gives 'foo' taking in sequences
template<class Model>
class interface
{
public:
template<typename SequenceT>
BOOST_CONCEPT_REQUIRES(
((concept<Model, SequenceT>)),
(void))
foo(SequenceT const& c) const
{
model_.foo(c);
}
private:
Model model_;
};
// a model that can handle fusion::sequence_base
class model
{
public:
template<typename SequenceT>
void foo(boost::fusion::sequence_base<SequenceT> const& b) const
{
SequenceT const& sequence = b.derived();
}
};
int main()
{
interface<model> bar;
bar.foo(boost::fusion::make_list(1,2,3));
};
==================end main.cpp==============================
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net