[ConceptGCC] |
ConceptGCC :Re: newbie question |
From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2006-11-27 17:34:57
Quoting Douglas Gregor <doug.gregor_at_[hidden]>:
> On Mon, 2006-11-27 at 09:41 +0100, Karl Meerbergen wrote:
> > I am a new conceptg++ user,
>
> Welcome!
>
> > Now I want to make a concept
> >
> > concept Foo<typename X> {
> > void X::bar() const ; // works, but not for concepts derived from
> Foo
> > } ;
> >
> > It is all fine for operators.
> > Attached is a file that does not compile. Any idea what I am doing
> > wrong?
>
> Your code is correct; this is a bug in the compiler. I have now
> fixed
> this bug in the Subversion version of ConceptGCC.
>
> Cheers,
> Doug
>
I see. Thanks for your prompt reply! I have another strange behaviour
which I am unable to develop a small test program for. I can describe it
as follows.
I have a templated function, with a where clause to put conditions on
the templated arguments, which works fine.
When I make it a functor, it does not work. I include a piece of code to
give you an idea, but as I said, I cannot generate a simple example.
The following piece of code (the function foo_function()) is ok.
template <DenseVectorCollection C, VectorExpression E>
where std::Assignable< typename C::dereference_type, typename
E::const_dereference_type >
&& std::Integral< typename C::size_type >
&& std::SameType< typename C::size_type, typename E::size_type >
void foo_function( C& c, E const& e ) {
typedef typename VectorExpression<E>::size_type size_type ;
assert( c.size() == e.size() ) ;
size_type size = e.size() ;
for (size_type i = 0 ; i < size ; ++i ) c(i) = e(i) ;
}
But then the functor version struct foo:
template <DenseVectorCollection C, VectorExpression E>
where std::Assignable< typename C::dereference_type, typename
E::const_dereference_type >
&& std::Integral< typename C::size_type >
&& std::SameType< typename C::size_type, typename E::size_type >
struct foo {
void operator() ( C& c, E const& e ) const {
typedef typename VectorExpression<E>::size_type size_type ;
assert( c.size() == e.size() ) ;
size_type size = e.size() ;
for (size_type i = 0 ; i < size ; ++i ) c(i) = e(i) ;
}
};
This produces the error message
vector.cpp: In member function void glas::foo<C, E>::operator()(C&,
const E&) const:
vector.cpp:25: error: no match for operator== in c->C::size() ==
e->E::size()
/usr/local/conceptgcc/4.1.1/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/bits/concepts.h:155:
note: candidates are: bool std::Integral<typename
glas::VectorExpression<C>::size_type>::operator==(const typename
glas::VectorExpression<C>::size_type&, const typename
glas::VectorExpression<C>::size_type&)
vector.cpp:26: error: size_type has no copy constructor
vector.cpp:27: error: conversion from int to non-scalar type
size_type requested
vector.cpp:27: error: no match for operator< in i < size
I have the impression that the where clause is not transferred to the
member function of the functor. Does ring a bell?
Karl