STL containers header guards.

T

tuko

Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?

I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.

Many thanks.

Tuko
 
J

John Harrison

tuko said:
Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?
No


I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.

Why not the obvious way?

#include <vector>
std::vector<double> foo;

Every header file should include the header files needed for it to compile.

john
 
C

Chris Gordon-Smith

tuko said:
Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?

I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.

Many thanks.

Tuko

If you were going to write an #ifndef line like the one shown above, then
you might just as well include the correct header in the first place.

If you really want to avoid a flood of errors, then you could always include
a file called 'library_headers.h' which itself includes all of the STL
headers that you use.

I doubt whether this is generally considered good style. Some of my code
that was originally written for C++ Builder does it, because its necessary
in order to get pre-compiled headers to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,479
Latest member
JaysonK723

Latest Threads

Top