If you have a my_function(utility::MyTool<...>)
, then I would say that my_function
belongs to the interface of the class template utility::MyTool<...>
. In other words, my_function
itself belongs to the namespace utility
.
This means that you can write code in the desired shorthand form:
namespace utility {
typedef MyTool<AFirstPolicy, ASecondPolicy> SomeTool;
my_function(SomeTool);
}
You can read more about interfaces and namespaces in this old column "What's In a Class" by Herb Sutter.
Note that even if you want to use functions in other namespaces with classes from namespace utility
, you can still reopen that namespace and define the policy class right there and do something like
// SomeHeader.hpp
namespace bla {
// your classes and functions
}
// reopen namespace utility
namespace utility {
typedef MyTool<AFirstPolicy, ASecondPolicy> SomeTool;
}
namespace bla {
typedef utility::SomeTool BlaTool; // or using-declaration
my_function(BlaTool);
}
This is of course more verbose than defining my_function
inside the utility namespace, but at least you can assemble all the various policies without too much typing.