[poppler] Some C++11 in poppler?

Carlos Garcia Campos carlosgc at gnome.org
Mon May 30 13:53:51 UTC 2016


Jakub Kucharski <jakubkucharski97 at gmail.com> writes:

> On Sun, 2016-05-29 at 22:50 +0200, Albert Astals Cid wrote:
>> Hi guys, what do you think of us adding "some" of the C++11 features
>> in 
>> poppler?
>> 
>> One that would be useful for example is std::unique_ptr, that is a
>> class that 
>> will take ownership of a pointer and delete it when it goes out of
>> scope.
>
> I think *some* C++11 features (e.g. std::unique_ptr) would make things
> easier. However there are some which could make things harder, e.g.
> type inference (auto) - it sometimes makes it hard to reason about the
> code when you don't know what type a function returns. So yes, some
>  C++11 features would be OK, but perhaps we could make guidelines for
> it.

Well, we could just document the cases where it could be used. We don't
use templates in poppler, so we don't have huge types where auto is
quite useful, but still there are cases where things look much better,
like in modern for loops:

for (auto foo : fooList)

also in cases where the type is twice like:

Foo* f = reinterpret_cast<Foo*>(b); -> auto f = reinterpret_cast<Foo*>(b);
or
Foo* f = std::make_unique<Foo>(); -> auto f = std::make_unique<Foo>();

> 		Jakub
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler

-- 
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 180 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20160530/3997184d/attachment.sig>


More information about the poppler mailing list