Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ - typedef/using for function template

I've got a following function template:

template<class A, class C, class B>
A doFoo(const B &val)
{
  //do something with C
}

Within my cpp file, all doFoo function will be used with one type for C. Is it possible to do such kind of typedef:

typedef myDoFoo<A, B> doFoo<A, ParticularC, B>

If it is - what is a correct syntax to do this?

like image 652
Dejwi Avatar asked Sep 16 '26 02:09

Dejwi


2 Answers

Just define another template function:

template<class A, class B>
A myDoFoo(const B &val)
{
  return doFoo<A,ParticularC,B>( val );
}

You may write a function:

template<class A, class B>
A myDoFoo(const B &val)
{
    return doFoo<A, ParticularC, B>(val);
}
like image 25
Jarod42 Avatar answered Sep 17 '26 20:09

Jarod42