Skip to main content
added 180 characters in body
Source Link

Here's a scenario:

suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file

but you use it, maybe

mp[whatever] = some;

should you re-include the <unordered_map> header? what is best practice?

in general, what's the best practice w.r.t relying on transitive includes like this, assuming that those things you are relying on are perhaps part of the method type signatures or member variables?

to be more explicit:

std::unordered_map<>

might occur in the header

but no way does the type appear in the implementation. An object of that type is only used.

Here's a scenario:

suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file

but you use it, maybe

mp[whatever] = some;

should you re-include the <unordered_map> header? what is best practice?

in general, what's the best practice w.r.t relying on transitive includes like this, assuming that those things you are relying on are perhaps part of the method type signatures or member variables?

Here's a scenario:

suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file

but you use it, maybe

mp[whatever] = some;

should you re-include the <unordered_map> header? what is best practice?

in general, what's the best practice w.r.t relying on transitive includes like this, assuming that those things you are relying on are perhaps part of the method type signatures or member variables?

to be more explicit:

std::unordered_map<>

might occur in the header

but no way does the type appear in the implementation. An object of that type is only used.

Source Link

Do you re-include system headers in the implementation files?

Here's a scenario:

suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file

but you use it, maybe

mp[whatever] = some;

should you re-include the <unordered_map> header? what is best practice?

in general, what's the best practice w.r.t relying on transitive includes like this, assuming that those things you are relying on are perhaps part of the method type signatures or member variables?