[Qgis-psc] QEP 314: Relax prohibition against "auto" for results of casting operations
Nyall Dawson
nyall.dawson at gmail.com
Sun Mar 9 13:13:23 PDT 2025
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!
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-psc/attachments/20250310/c05eee2c/attachment.htm>
More information about the QGIS-PSC
mailing list