You cannot pass in a typename
as a normal function argument, i.e. your snippet
using UGS12_FMT = some_type;
auto file = CreateFile(4,3,2,UGS12_FMT); // error
will never work (except when you make CreateFile
a macro, which is strongly discouraged).
Instead, you can essentially use one of three alternative techniques.
Overload the function to take different arguments of empty type (so-called tag-dispatching):
// declarations of tag types
struct format1 {} fmt1;
struct format2 {} fmt2; // etc
// overloaded file creation functions
file_type CreateFile(args, format1);
file_type CreateFile(args, format2);
// usage:
auto file = CreateFile(4,3,2,fmt1); // use format1
Use a template
(and specialise it for different format types)
template<typename Format>
file_type CreateFile(args); // generic template, not implemented
template<> file_type CreateFile<Format1>(args); // one speciliasation
template<> file_type CreateFile<Format2>(args); // another speciliasation
auto file = CreateFile<Format1>(4,3,2); // usage
Pass the information using an enum
type.
enum struct format {
f1, // indicates Format1
f2 }; // indicates Format2
file_type CreateFile(args,format);
auto file = CreateFile(4,3,2,format::f1);
Finally, you can combine these various approaches using traits
classes as similar techniques.