Bug #1396

Char-Mapping arithmetics do not compile

Added by M. Rolf about 11 years ago. Updated about 11 years ago.

Status:ResolvedStart date:02/05/2013
Priority:NormalDue date:
Assignee:M. Rolf% Done:

100%

Category:-
Target version:NemoMath 0.4

Description

The expression arg<char>()+1, for instance in

Mapping<char,char> i = arg<char>()+1;

does not compile, while just arg<char>() does compile.

GCC:

nemomath/trunk/nemomath/src/nemo/Mapping.h: In member function ‘nemo::MappingDefinition<OutType, InType>* nemo::AddMappingConst<InType, InnerOutType1, InnerOutType2, OutType>::getInverse() const [with InType = char, InnerOutType1 = char, InnerOutType2 = int, OutType = int]’:
nemomath/trunk/nemomath/src/nemo/Mapping.h:450: error: no matching function for call to ‘nemo::AddMappingConst<char, char, int, int>::AddMappingConst(nemo::IntrusivePtr<nemo::MappingDefinition<int, int> >, int)’
nemomath/trunk/nemomath/src/nemo/Mapping.h:450: note: candidates are: nemo::AddMappingConst<InType, InnerOutType1, InnerOutType2, OutType>::AddMappingConst(const nemo::IntrusivePtr<nemo::MappingDefinition<InType, OutType> >&, const InnerOutType2&) [with InType = char, InnerOutType1 = char, InnerOutType2 = int, OutType = int]
nemomath/trunk/nemomath/src/nemo/Mapping.h:450: note:                 nemo::AddMappingConst<char, char, int, int>::AddMappingConst(const nemo::AddMappingConst<char, char, int, int>&)

Condensed:
nemomath/src/nemo/Mapping.h: In member function ‘nemo::MappingDefinition<int,char>* nemo::AddMappingConst<char,char,int,int>::getInverse() const’:
nemomath/src/nemo/Mapping.h:450: error: no matching function for call to ‘nemo::AddMappingConst<char, char, int, int>::AddMappingConst(nemo::IntrusivePtr<nemo::MappingDefinition<int, int> >, int)’
           note: candidates are: nemo::AddMappingConst<char,char,int,int>::AddMappingConst(const nemo::IntrusivePtr<nemo::MappingDefinition<char,int> >&, const int&)
           note:                 nemo::AddMappingConst<char,char,int,int>::AddMappingConst(const nemo::AddMappingConst<char,char,int,int>&)

History

#1 Updated by M. Rolf about 11 years ago

Same problem for arg<float>()+(double)1:

nemomath/trunk/nemomath/src/nemo/Mapping.h: In member function ‘nemo::MappingDefinition<double,float>* nemo::AddMappingConst<float,float,double,double>::getInverse()’:
nemomath/trunk/nemomath/src/nemo/Mapping.h:449: error: no matching function for call to ‘nemo::AddMappingConst<float,float,double,double>::AddMappingConst(nemo::IntrusivePtr<nemo::MappingDefinition<double,double> >, double)’
          note: candidates are: nemo::AddMappingConst<float,float,double,double>::AddMappingConst(const nemo::IntrusivePtr<nemo::MappingDefinition<float,double> >&, const double&)
          note:                 nemo::AddMappingConst<float,float,double,double>::AddMappingConst(const nemo::AddMappingConst<float,float,double,double>&)

#2 Updated by M. Rolf about 11 years ago

There is indeed a cast necessary during the algebraic inversion:

Take types A and B, an operator +:(AxB)->B. Inverting the expression f of argument x and constant c

B::f = A::x + B::c

gives
B::f + B::rightInv<B>(B::c) = A::x

The left-hand side needs to be casted from B to A in order to obtain x

#3 Updated by M. Rolf about 11 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
Solved:
  1. Introduced new casting function for output type of mappings, accessible via reinterpret<NewOutType>(Mapping<InType,OutType>)
  2. Internal usage of that functionality in invertible-operator-mappings (like +/*), fixes problem described above
  3. Thereby circumvented annoying GCC bug that sometimes confused decltype<A()°B()> with decltype<B()°B()>. Magic fix: use existing values a inside decltype instead of default-construction A() whenever possible: decltype<a°B()>

Also available in: Atom PDF