Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-15 Thread Konstantin Tokarev


15.06.2016, 18:02, "Thiago Macieira" :
> On quarta-feira, 15 de junho de 2016 15:44:09 PDT Giuseppe D'Angelo wrote:
>>  Il 14/06/2016 19:01, Sune Vuorela ha scritto:
>>  > You can pass your own classes as handlers, provided that they have a
>>  > public static function void cleanup(T *pointer).
>>  >
>>  > - from the documentation.
>>
>>  However, you can't pass a per-QScopedPointer unique deleter object,
>>  which also makes this part of the API sub-par compared with the Standard...
>
> Or, if you look at the same problem from a different angle, since
> QScopedPointer has the same size as a regular pointer, allowing you to replace
> a regular pointer in a class with it, without causing a binary compatibility
> break, its API is better than the Standard.

std::unique_ptr always has the same size as pointer.

std::unique_ptr is different type (thought it also has the same 
size as pointer if Deleter is stateless)

-- 
Regards,
Konstantin
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-15 Thread Thiago Macieira
On quarta-feira, 15 de junho de 2016 15:44:09 PDT Giuseppe D'Angelo wrote:
> Il 14/06/2016 19:01, Sune Vuorela ha scritto:
> > You can pass your own classes as handlers, provided that they have a
> > public static function void cleanup(T *pointer).
> > 
> >   - from the documentation.
> 
> However, you can't pass a per-QScopedPointer unique deleter object,
> which also makes this part of the API sub-par compared with the Standard...

Or, if you look at the same problem from a different angle, since 
QScopedPointer has the same size as a regular pointer, allowing you to replace 
a regular pointer in a class with it, without causing a binary compatibility 
break, its API is better than the Standard.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-15 Thread Giuseppe D'Angelo

Il 14/06/2016 19:01, Sune Vuorela ha scritto:

You can pass your own classes as handlers, provided that they have a
public static function void cleanup(T *pointer).

  - from the documentation.


However, you can't pass a per-QScopedPointer unique deleter object, 
which also makes this part of the API sub-par compared with the Standard...


Cheers,

--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts



smime.p7s
Description: Firma crittografica S/MIME
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-14 Thread Sune Vuorela
On 2016-06-14, Konstantin Tokarev  wrote:
> QScopedPointer lacks custom deleters which make it unusable for the purpose 
> of managing Windows HANDLEs (see original post).

You can pass your own classes as handlers, provided that they have a
public static function void cleanup(T *pointer).

 - from the documentation.

/Sune

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-14 Thread Konstantin Tokarev


14.06.2016, 18:03, "Bo Thorsen" :
> Den 13-06-2016 kl. 12:16 skrev Denis Shienkov:
>>>  QScopedPointer?
>>
>>  Do you have real example? ;)
>
> Well, as Sean wrote it lacks the move, but if all you're after is to use
> it for a pointer in a class or make a local dynamically allocated var
> exception safe, then QScopedPointer is fine. It's limited in it's use,
> but that doesn't mean it's unusable.

QScopedPointer lacks custom deleters which make it unusable for the purpose of 
managing Windows HANDLEs (see original post).

However, author of [1] argues that managing non-pointer resources with 
unique_ptr + custom deleter is sub-par, and proposes different approach based 
on explicit specialization

[1] http://accu.org/index.php/journals/2086

-- 
Regards,
Konstantin
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-14 Thread Bo Thorsen

Den 13-06-2016 kl. 12:16 skrev Denis Shienkov:

QScopedPointer?


Do you have real example? ;)


Well, as Sean wrote it lacks the move, but if all you're after is to use 
it for a pointer in a class or make a local dynamically allocated var 
exception safe, then QScopedPointer is fine. It's limited in it's use, 
but that doesn't mean it's unusable.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-13 Thread Denis Shienkov
> QScopedPointer?

Do you have real example? ;)

2016-06-13 7:47 GMT+03:00 Bo Thorsen :

> Den 12-06-2016 kl. 12:59 skrev Denis Shienkov:
>
>> No, use of the C++11 Standard Library features is not permitted
>>>
>>
>> Lousy to hear it...
>>
>> How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE,
>> HKEY, HDEVINFO and other stuff)?
>>
>
> QScopedPointer?
>
> Bo Thorsen,
> Director, Viking Software.
>
> --
> Viking Software
> Qt and C++ developers for hire
> http://www.vikingsoft.eu
>
> ___
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-13 Thread Иван Комиссаров
If we don't have unique_ptr, then, probably, we don't have move semantics
too

2016-06-13 10:51 GMT+03:00 Sean Harmer :

> On Monday 13 June 2016 06:47:44 Bo Thorsen wrote:
> > Den 12-06-2016 kl. 12:59 skrev Denis Shienkov:
> > >> No, use of the C++11 Standard Library features is not permitted
> > >
> > > Lousy to hear it...
> > >
> > > How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE,
> > > HKEY, HDEVINFO and other stuff)?
> >
> > QScopedPointer?
>
> Not moveable.
>
> Sean
> --
> Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
> Klarälvdalens Datakonsult AB, a KDAB Group company
> Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
> KDAB - Qt Experts - Platform-independent software solutions
> ___
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-13 Thread Sean Harmer
On Monday 13 June 2016 06:47:44 Bo Thorsen wrote:
> Den 12-06-2016 kl. 12:59 skrev Denis Shienkov:
> >> No, use of the C++11 Standard Library features is not permitted
> > 
> > Lousy to hear it...
> > 
> > How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE,
> > HKEY, HDEVINFO and other stuff)?
> 
> QScopedPointer?

Not moveable.

Sean
--
Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-12 Thread Bo Thorsen

Den 12-06-2016 kl. 12:59 skrev Denis Shienkov:

No, use of the C++11 Standard Library features is not permitted


Lousy to hear it...

How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE,
HKEY, HDEVINFO and other stuff)?


QScopedPointer?

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-12 Thread Thiago Macieira
On domingo, 12 de junho de 2016 13:59:32 PDT Denis Shienkov wrote:
>  > No, use of the C++11 Standard Library features is not permitted
> 
> Lousy to hear it...
> 
> How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE,
> HKEY, HDEVINFO and other stuff)?

You can use it if you know all compilers compiling that code will support it.

> BTW: But, I saw unique_ptr in qtbase and qt3d sources...

In qtbase, it's found in:

src/3rdparty/angle/src/libANGLE/Error.h
src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
src/3rdparty/pcre/sljit/sljitNativeARM_32.c
src/gui/text/qfontengine_p.h
src/plugins/platforms/mirclient/qmirclientscreen.cpp
src/plugins/platforms/mirclient/qmirclientwindow.cpp
src/plugins/platforms/mirclient/qmirclientwindow.h

And the qfontengine_p.h match is:
class Holder { // replace by std::unique_ptr once available


-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-12 Thread Denis Shienkov

> No, use of the C++11 Standard Library features is not permitted

Lousy to hear it...

How to do then RAII to avoid a leaks e.g. for Windows handles (HANDLE, 
HKEY, HDEVINFO and other stuff)?


BTW: But, I saw unique_ptr in qtbase and qt3d sources...

12.06.2016 1:10, Thiago Macieira пишет:

On sábado, 11 de junho de 2016 17:25:40 PDT Denis Shienkov wrote:

Hi all...

Is it possible now?

No, use of the C++11 Standard Library features is not permitted, outside of
inline code with #ifdef.



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-11 Thread Thiago Macieira
On sábado, 11 de junho de 2016 17:25:40 PDT Denis Shienkov wrote:
> Hi all...
> 
> Is it possible now?

No, use of the C++11 Standard Library features is not permitted, outside of 
inline code with #ifdef.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] Can we use std::unique_ptr in Qt base/modules sources since Qt5.7 ?

2016-06-11 Thread Denis Shienkov

Hi all...

Is it possible now?

BR,

Denis





___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development