Boost logo

Boost :

Subject: Re: [boost] [forward_declare] Interest Inquiry toward Faster Compile Times
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2012-08-02 07:52:14


On Aug 2, 2012, at 3:17 AM, Olaf van der Spek <ml_at_[hidden]> wrote:

> On Thu, Aug 2, 2012 at 2:36 AM, Daniel Larimer <dlarimer_at_[hidden]> wrote:
>> I have been increasingly frustrated with how long it takes to compile c++ code. After spending some time in Java and C# I can feel the pain of compile times much sharper than I use to. After seeing that Java and C# were able to achieve some level of generics without requiring 'everything in the header' and knowing that C compiles an order of magnitude faster than c++ I set about to find a way to increase my compile times.
>
> Did you try PCH (precompiled headers)?

Yes, PCH have their own problems and are ineffective for situations where you are actively editing the headers. The compiler still has to process them too.

>
>> One of the common recommendations is to 'forward declare' everything and to use the PIMPL (private implementation pattern). Unfortunately, PIMPL usually implies heap allocation and if you ever want to return-by-value you are stuck including the entire header for the types you use in your header.
>
> It'd be nice if a future version of C++ allowed pimpl without space overhead.
>
        Keep in mind the other use case is this:
        
class X {
        public:
        fwd<test,24> getByValue()const;
}

        Not shown in my initial example is that fwd<> automatically casts to test or anything test automatically casts to. In this case, even an efficient malloc will not save class X. Perhaps fwd<> could be implemented via the heap... but that is an expensive way to solve the alignment problem.

> Olaf
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk