0

Is there any way to reduce the number of times you have to write:

template<typename T>

for a bunch of functions all using the same template parameters?

i.e., something like this:

template<typename T>
namespace my_functions_using_T {

T function_do_something(const T & t);

void function_do_something_else(T & t);
}


(besides making them all methods of a class... which seems heavy handed...?)

Edited by Kikazaru: anticipation of obvious answer...

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Kikazaru
Featured Replies
  • [QUOTE=Kikazaru;1144469]Is there any way to reduce the number of times you have to write: template<typename T> for a bunch of functions all using the same template parameters? i.e., something like this: template<typename T> namespace my_functions_using_T { T function_do_something(const T & t); void function_do_something_else(T & t); } (besides making them all … Read More

1

Is there any way to reduce the number of times you have to write:

template<typename T>

for a bunch of functions all using the same template parameters?

i.e., something like this:

template<typename T>
namespace my_functions_using_T {

T function_do_something(const T & t);

void function_do_something_else(T & t);
}


(besides making them all methods of a class... which seems heavy handed...?)

Nope. Don't be that lazy.

0

You can calculate the last 10 digits of each term in the sequence and add them up.

To calculate the last ten digits of n^n do this:

unsigned long result[1000];
for(n=1; n<1000; n++) {
result[n] = 1;
for(i=0; i<n; i++)
result = (result * n) % 10;
}

better check the bounds in the loops... I didn't bother.

There's probably a cooler way, but this shouldn't take too long to compute.

0

Man... what the hell am I doing... I tried to reply to a question that was shown below...

Anyway, thanks for the answer.

Laziness is a virtue! :)

It seems rather remiss not to provide for this functionality, since you can end up with template definitions all over the place making things hard to figure out...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.