[Qgis-psc] QEP 314: Relax prohibition against "auto" for results of casting operations
Nyall Dawson
nyall.dawson at gmail.com
Mon Mar 10 15:29:54 PDT 2025
On Mon, 10 Mar 2025 at 06:13, Nyall Dawson <nyall.dawson at gmail.com> wrote:
>
>
>
> On Mon, 24 Feb 2025, 8:31 am Nyall Dawson, <nyall.dawson at gmail.com> wrote:
>>
>> Hi all,
>>
>> Please see https://github.com/qgis/QGIS-Enhancement-Proposals/pull/330
>> for a proposed change to the QGIS coding policies to relax the current
>> prohibition against use of "auto" in some (more!) new cases.
>>
>> (This follows up recent changes to permit auto for smart pointer types, see https://github.com/qgis/QGIS-Enhancement-Proposals/pull/319)
>>
>> This change relaxes the prohibition against auto to allow use of auto for variable types when the variable type is explicitly stated during its initialization as the result of a cast operation, such as dynamic_cast, static_cast, const_cast, reinterpret_cast, qobject_cast,
>> qgsgeometry_cast, or qgis::down_cast
>
>
> This proposal has passed the 2 week discussion phase and is ready for voting now.
>
> Vote away!
Declaring as passed with approval from @alexbruy , @rouault , @elpaso, @uclaros
Nyall
>
>
> Nyall
>
>
>
>
>>
>> Specifically:
>>
>> // allowed, the pointer types are explicit during initialization:
>> auto markerSymbol = dynamic_cast< QgsMarkerSymbol* >( symbol );
>> auto vectorLayer = qobject_cast< QgsVectorLayer* >( layer );
>> if ( auto lineString = qgsgeometry_cast< const QgsLineString* >( geometry ) ) { ... }
>>
>> // NOT allowed, the type is not explicit:
>> auto myLineStringPtr = downcastGeometryAsLineString( geometry );
>>
>> Please keep discussion on
>> https://github.com/qgis/QGIS-Enhancement-Proposals/pull/330 so that we
>> have a formal record of the discussion.
>>
>> Thanks all!
>> Nyall
>>
More information about the QGIS-PSC
mailing list