I want to remove, if possible, the includes of both
With the exception of adding overloads to std::swap
(the only exception I can think of right now), you are generally not allowed to add anything to the std
namespace. Even if it were allowed, the actual declaration for std::vector
is a lot more complicated than the code in the OP. See Nikolai N Fetissov's answer for an example.
All that aside, you have the additional problem of what your class users are going to do with functions that return a std::vector
or std::string
. The C++ Standard section 3.10 says that functions returning such objects are returning rvalues, and rvalues must be of a complete type. In English, if your users want to do anything with those functions, they'll have to #include
or #include
the headers for them in your .h
file and be done with it.