I think this is the spirit of C ++ - you do not pay for what you do not want (you obviously pay for what you need):
#include <iosfwd>
template< class T >
class QVector;
struct A
{
void process( QVector<int> );
void print( std::ostream& );
};
#include "a.h"
#include <iostream> // I need only A::print() in this module, not full interface
...
A().print( std::cout );
...
That's why I think it’s unfair to prevent a developer from working this way with STL ( Will there be declaration files in C ++ 11 STL? ).
But also I see one bad thing : the dependencies of module A will spread in the external context (duplication of directives #include), and this can lead to hard refactoring when the interface changes (for example, replace QVector with QList - and now you need to replace all the entries <QVector>with <QList>).
Solution to this problem:
#include <iostream>
#include <QVector>
struct A
{
void process( QVector<int> );
void print( std::ostream& );
};
" " -
(
)? ,
(, Qt ).
- ( ):
#include <iosfwd>
template< class T >
class QVector;
struct A
{
void process( QVector<int> );
void print( std::ostream& );
};
#include <iostream>
#include <QVector>
#include "a_decl.h"
, .
? ? ?
( )
UPDATE:
boost 1.48.0 Container, undefined ( ).