Just wanted to throw this out there. I'd even prefer something like this in the single context this trick actually works.
Code:
template <typename T, std::size_t retval>
inline std::size_t SizeOf ( T (&foo)[retval] )
{
return retval;
}
Thing thingconstructed(something, SizeOf(something));
Thing has a constructor with the dreaded size parameter of course.
Even more problematic: Ignoring the bad function name, in C++11 constexpr might work out better than inline anyway, but constexpr has rules, and this isn't important, so I can't be bothered. Applying the trick to every possible instance just grinds my gears.