[cfe-dev] Working with ConceptClang: Binding input arguments to functions.

Fletcher, John P j.p.fletcher at aston.ac.uk
Fri Apr 22 04:51:46 PDT 2011


Larisse Voufo

I don't have a solution to this, but here is a related code which does work using the concept clang.

What it shows is that the lookup which fails in the concept works outside it.  Something in the concept context is messing it up.

John Fletcher

template <typename AType>
AType hh(AType a) {
  return a;
}

template <typename AType>
AType ff(AType a) {
  AType b = a;
  return b;
}


explicit concept A<typename T, typename AType > {

    AType h(AType a) {
        return a;
    }

    AType f(AType a) {
      AType b = 10;// = a; NOTE: the accessing of a fails here.
        return b;
    }
}

concept_map A<int, char> {
  //    typedef char AType;
}

template<typename T, typename U>
requires (A<T,U>)
void func(T a,U b) {
  //U x = h(b);         // <-- Instantiation DOES NOT WORK
  U y = f(b);          // <-- Instantiation WORKS
}

int main(int argc, char **argv)
{
  func<int,char>(10, 'a');   // Fails with declaration for 'x', for passes
                             // with declaration of 'y'.
  int a = hh(10);
  int b = ff(20);
    return 0;
}





More information about the cfe-dev mailing list