On Thu, Mar 15, 2012 at 2:34 PM, Marc Glisse <marc.glisse@xxxxxxxx> wrote: > On Thu, 15 Mar 2012, Zack Weinberg wrote: >> const K good(1); // should compile >> const K bad(999); // should not compile > > You'ld want constexpr on those too (if there was any chance). ... why? > constexpr has nothing to do with const or volatile, it is closer to static > if you want a comparison... I admit I don't fully understand constexpr, but this doesn't clarify things _at all_ for me. >> Any advice? Solutions that work with 4.6 *strongly* preferred. > > Use a factory: make_K<1>() or make_K<999>() ? This class already has too much boilerplate. Also, it does not help with the other situation where I need constructor value checks: an class B whose instances do _not_ represent constants, but which should only be initializable from K instances, B instances, or the integer literal 0. (I have a kludge for that involving std::nullptr_t, but I don't like it.) zw