On Sun, Dec 02, 2007 at 09:17:08AM +0100, Abdelrazak Younes wrote:
> Andre Poenitz wrote:
>> On Sat, Dec 01, 2007 at 10:23:17AM -0000, [EMAIL PROTECTED] wrote:
>>> Modified: lyx-devel/trunk/src/support/FileName.h
>>> URL: 
>>> http://www.lyx.org/trac/file/lyx-devel/trunk/src/support/FileName.h?rev=21896
>>> ==============================================================================
>>> --- lyx-devel/trunk/src/support/FileName.h (original)
>>> +++ lyx-devel/trunk/src/support/FileName.h Sat Dec  1 11:23:16 2007
>>> @@ -15,6 +15,7 @@
>>>  #include "support/strfwd.h"
>>>   #include <ctime>
>>> +#include <vector>
>>   Looks like I have no chance to keep that out. First Abdel, now you ;-}
>> Seriously. dirList() is used exactly once in out code, FileName.h gets
>> included in almost every file, yet quite a bit of the frontend does not
>> need <vector>.
>
> I know that but my rationale was that filetools.h is even more wide spread 
> than FileName.h (73 versus 48).
>
>> So I'd like to keep it out. Unfortunately, forward
>> declaration of vector is not as straightforward as e.g. for string and
>> ostream.
>
> How is it that Qt manage to forward declare things like QFileInfoList?

It's  

  template <typename T> vector<T, Alloc = std::allocator<T>

vs 

  template <typename T> QVector<T>.

The problem is the default argument. It's allowed to specify it only 
once, even if subsequent specifications are identical. 

I.e.

  template <typename T> vector<T, Alloc = std::allocator<T> >;
  template <typename T> vector<T, Alloc = std::allocator<T> >;

is illegal, whereas

  template <typename T> QVector<T>;
  template <typename T> QVector<T>;

is not.

Now, since the default argument always specified when doing #include
<vector>, it is basically impossible to do it anywhere else.

The problem is not there for QVector<>.

[Btw, due to the actual implementation one can even have
        struct Foo {  QVector<Foo> fooChildren_; };
and similar, which is not possible for std::containers.]

> I wonder why C++ forbids forward declaration of typedef...
>  typedef vector<FileName> FileNameList.

There are quite a few annoyances in the Standard that make a
programmer's life harder than it needs to be...

> The easy way out is to create a class:
>
> class FileNameList : public vector<FileName> {}
>
> This is not just about dirList, I expect we would use this type for many 
> other methods.

So just use it ;-)

Andre'

Reply via email to