Вопрос

I want to reduce the amount of maintenance I have to do to my code when things change.

In a certain header file I have something long and kind of verbose like this:

extern std::map<event_t, std::multimap<real_t, event>> event_schedule;

Then, in a cpp file, I thought it would be easier to actually declare it like so;

decltype(event_schedule) event_schedule;

Is there any reason not to?

Это было полезно?

Решение

Nope, there is no reason not to.

The only argument that can probably be made against that is that "you can't see the type". This argument has been brought up for auto quite a bit and has never really managed to "get attention". You usually care about what you can do with the type rather than how shiny the actual name of the type is really.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top