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

Larisse Voufo lvoufo at cs.indiana.edu
Fri Apr 22 06:22:03 PDT 2011


Hi John --

Indeed, the example you have below is supposed to work as argument binding
for the functions hh() and ff() is equivalent that for func. The problem
occurs when I'm trying to continue binding those arguments throughout
(inner) calls to associated types, in cases where function templates are
actually constrained.

Thanks for pointing it out though. It certainly helps clarify my point.

-- Larisse.


On Fri, Apr 22, 2011 at 7:51 AM, Fletcher, John P
<j.p.fletcher at aston.ac.uk>wrote:

> 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;
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110422/99e6717f/attachment.html>


More information about the cfe-dev mailing list