unique_ptr header question
markus.mohrhard at googlemail.com
Sun Apr 23 23:14:36 UTC 2017
On Mon, Apr 24, 2017 at 1:04 AM, Chris Sherlock <chris.sherlock79 at gmail.com>
> Hi all,
> I'm getting some build failures on Jenkins. It seems there is a
> compilation failure because there are a number of files that use
> std::unique_ptr but done include <memory>.
> I think it may have come from here:
> The only thing is: Jenkins did a full build without any errors, so I'm
> scratching my head what has happened here...
> I guess I'm interested: do we need to include <memory> when using
> unique_ptr, and if so how did Jenkins manage to fully compile this code on
> all platforms?
I suppose that the question is related to
The patch that you referenced is correct and the code compiles because
header files are recursively included. So if any of the header files in the
include chain contains an "#include <memory> std::unique_ptr will be
available in that translation unit.
Now coming back to your patch, you changed the include chain for a number
of files by no longer including a header file that will bring in the
"memory" file. Therefore you need to fix the places that start to complain
now manually and add the #include <memory> into these files.
Regarding the question whether to include "memory" everytime you use
std::unique_ptr is a bit of a style question. There are people who advocate
to always include all necessary headers and to never rely on what the
included headers already include but at least in my opinion that often
leads to many include statements at the beginning of a file. IMHO the more
important part is to remove include lines that are not necessary any more.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the LibreOffice