c++ - How do I force a specific instantiation of a templated function without repeating its signature? -


i need instantiate templated function foo() long signature, specific template arguments.

i read answers this question suggest copying function signature setting specific arguments. want avoid somehow. reasonable way achieve this? e.g. allow me write

instantiate(foo, template_arg1, template_arg2); 

or maybe

myfunctiontype<template_arg1, template_arg2> foo; 

just illustrative purposes, suppose code foo:

template<typename t, int val> unsigned foo(     t bar,     sometype baz1,     someothertype baz2,     yetanothertype you_catch_the_drift)  {      /* code here */  } 

in explicit instantiations of function templates it's possible omit template parameter list after template-id if arguments can deduced:

template<typename t> void foo(t) {} template void foo(int); // explicit instantiation //               ^ no template parameter list here 

not in case, though, since val parameter needs passed explicitly. how explicit instantiation like:

template unsigned foo<int, 0>(int, char, double, float); 

is bad? can write macro avoid duplication, looks there isn't of in first place.


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -