There are known ways to manipulate the type of an integer literal
0L; // long
3U; // unsigned integer
1LL; // long long
What I need is a way to initialize an integer literal to std::size_t
. I supposed that doing
2U; // unsigned int
would be enough, but I still get a compiler error when calling a function template that expects two arguments of the same integral type (no matching function to call for func(unsigned int, size_t
)
I know/verified that explicitly casting ( static_cast<std::size_t>(1)
) the first argument solves the problem but I'm asking if there's a prettier solution
EDIT
the function has a signature
template <class T> const T& func(const T& a, const T& b);
EDIT2
I don't know if this question is to "blame" but I'm happy to announce that this is upcoming (cudos @malat for mentioning this in the comments)
question from:https://stackoverflow.com/questions/22346369/initialize-integer-literal-to-stdsize-t