[ConceptGCC] |
ConceptGCC :Re: newbie question |
From: Marcin Zalewski (zalewski_at_[hidden])
Date: 2006-11-29 04:02:35
Karl,
Where did you insert a late_check? I am not sure if this is something
that really solves the problem. I can't really see why would you get the
error you are getting (a bug?) but I think that you could template the
operator() instead of the whole structure. If you do it that way you
would not have to instantiate the structure for all different uses but
only implicitly instantiate the operator.
-m
Karl Meerbergen wrote:
> The problem I posted yesterday is solved: I inserted late_check.
>
> Karl
>
>
>> 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