N
Nike
I have a small question w.r.t usage of default arguements in
template..
I shall try to elaborate this with an example..
let's say I have some template function , where EntryType is the input
for the template fn 1.. and another type where EntryType and lass P1
are both inputs..
case1 (1)template<class EntryType_>
i.e void A<EntryType_>::createObject(EntryType::inputIdType
inpId_ )..
case2 (2)EntryType and class P1 are the input for the template fn 1
template<class EntryType_, class P1>
i.e void A<EntryType_>::createObject(EntryType::inputIdType
inpId_ )..
Inside this function, I call the class constructor based on the number
of input parameters passed ..
I have similar 25 functions(Function overloading) where the difference
is going to be only in the number of arguements passed as input..(This
function is part of the base project)..
Now , for a new reqmt., I need to add a boolean to the create object
function..
It looks tedious for me to add the boolean in all the 25 template
functions as I feel the functionality is going to be the same in all
the 25 functions..
Ideally, what I would prefer is to have one single function with all
the parameters inside it..If I don't pass a parameter , let say in
case 2 of the above declaration , i should call case1
Normally, without the template this is possible with the usage of
default arguements as avbl in c++.
But for template this is not possible as the template function will
not know what kind of objects this is instantiating..
template..
I shall try to elaborate this with an example..
let's say I have some template function , where EntryType is the input
for the template fn 1.. and another type where EntryType and lass P1
are both inputs..
case1 (1)template<class EntryType_>
i.e void A<EntryType_>::createObject(EntryType::inputIdType
inpId_ )..
case2 (2)EntryType and class P1 are the input for the template fn 1
template<class EntryType_, class P1>
i.e void A<EntryType_>::createObject(EntryType::inputIdType
inpId_ )..
Inside this function, I call the class constructor based on the number
of input parameters passed ..
I have similar 25 functions(Function overloading) where the difference
is going to be only in the number of arguements passed as input..(This
function is part of the base project)..
Now , for a new reqmt., I need to add a boolean to the create object
function..
It looks tedious for me to add the boolean in all the 25 template
functions as I feel the functionality is going to be the same in all
the 25 functions..
Ideally, what I would prefer is to have one single function with all
the parameters inside it..If I don't pass a parameter , let say in
case 2 of the above declaration , i should call case1
Normally, without the template this is possible with the usage of
default arguements as avbl in c++.
But for template this is not possible as the template function will
not know what kind of objects this is instantiating..