bearophile wrote: > Nick Sabalausky: > >>> If you don't want that doplication you can also write: >>> enum auto f = Foo(); >> Can't you do: >> enum f = Foo(); >> ? > > In my opinion that's a semantic mess, I don't write that. auto is for > automatic local type inference and enum is to ask for a compile time constant.
No it isn't. 'auto' is a storage class, it has NOTHING to do with type inference. Type inference is triggered when the type is omitted from a declaration. It just turns out that in the majority of cases (variables), the easiest way to do this is to use the default storage class which is used if you don't otherwise specify one: auto. This is why 'const blah = 42;' works: const is used as a storage class and the type is omitted.