Templates are compile-time constructs. If you really need to do it for performance reasons. Then you will need to implement a switch on the variable:
switch(base)
{
case 1: process<1>(); break;
case 2: process<2>(); break;
case 3: process<3>(); break;
case 4: process<4>(); break;
...
}
...
template<int N>
void process()
{
// Now you can proceed with rest of logic with templatized type
Klasa_nk5<N> klasa_nk5;
...
Also in C++11, you should be able to make some generic construct like,
template<typename Functor, typename... Args>
void mapToTemplate(Functor&& process, Args&& ...args)
{
switch(base)
{
case 1: process<1>(std::forward<Args>(args)...); break;
case 2: process<2>(std::forward<Args>(args)...); break;
...
}
}
which can then be used as,
mapToTemplate([/* caputures */](/*Whatever data needs to be passed on*/){
...
}, ...);
On top of that it should be possible to reduce the typing required for individual cases using BOOST_PP_REPEAT from boost preprocessor library.