Consider the following code:
template<int complexity>
class Widget
{
public:
Widget(int size);
};
int main()
{
Widget<4> widget(12); // not easily readable if definition of Widget in some faraway header
return 0;
}
Another try using conversion to enumeration type as named parameters:
enum ComplexityInt : int {};
enum SizeInt : int {};
template<ComplexityInt complexity>
class Widget
{
public:
Widget(SizeInt size);
};
int main()
{
Widget<(ComplexityInt) 4> widget((SizeInt) 12);
return 0;
}
Is the second example completely fine C++ code without some undesirable side effects or additional costs? And what are your thoughts about it from the style and readability perspectives?