Is there any way to implement a scope change for the template keyword? I have a templated class with almost 100 different functions and my code looks disgusting with my external declarations. Is there any way to implement a scope increase for template? EG:

template <typename Type>
class TypeClass
{
    public:
    Type a();
    Type b();
    Type c();
};
//Without template scope:
template <typename Type>
TypeClass<Type> A();
template <typename Type>
TypeClass<Type> B();
template <typename Type>
TypeClass<Type> C();
//With template scope:
template w/ scope <typename Type>
TypeClass<Type> A();
TypeClass<Type> B();
TypeClass<Type> C();

Is this at all possible, or should I just copy "template <typename Type>" into my clipboard and reuse it?

Something is bothering me about your situation, I have a sneaking suspicion there may be a design issue.

As far as I know, and as I understand your query, what you have demonstrated as your specific intent is not possible, but there are things you can do to clean up your code.

What exactly are you trying to accomplish? Where in your code do these declarations appear? Are they in a cpp file or are they in a header?

The code is in a header file, it is a statistics header that deals with dynamic arrays, and allows for convolution of said arrays, and calculation of certain statistical properties, such as standard deviation of said arrays.

Unfortunately, template code tends to get ugly because of how it works, it's just the nature of the beast. This sounds more like you're just trying to save yourself some typing though.

About the only way you could get away from repeatedly writing the template header is to implement your member functions within the class declaration itself, but it's not usually the best solution because it makes the class' declaration hard to read. Of course, this won't address the "issue" for the non-member functions...

You could also string them together into one line. There's nothing that says a template header has to be 2 lines:

template <typename T> MyClass<T> someFunction(T);
template <typename T> MyClass<T> someFunction2(T *);
template <typename T> MyClass<T> someFunction3(T);
template <typename T> MyClass<T> someFunction4(T &);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.