From 97a2757e394d967fec4473fae79d3ee9a057f0d3 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Tue, 14 Sep 2021 16:12:50 +0200 Subject: [PATCH] Added missing noexcept specifiers Reported as "C26440 Function ... can be declared noexcept" --- .../Cesium3DTilesSelection/CreditSystem.h | 13 ++++--- .../Cesium3DTilesSelection/RasterOverlay.h | 8 +++-- .../RasterOverlayTile.h | 14 +++++--- .../include/Cesium3DTilesSelection/Tileset.h | 2 +- Cesium3DTilesSelection/src/BoundingVolume.cpp | 16 ++++----- Cesium3DTilesSelection/src/CreditSystem.cpp | 6 ++-- Cesium3DTilesSelection/src/Tile.cpp | 8 ++--- .../src/TileContentFactory.cpp | 2 +- .../CesiumAsync/Impl/ImmediateScheduler.h | 7 ++-- CesiumAsync/include/CesiumAsync/Promise.h | 4 +-- CesiumAsync/include/CesiumAsync/ThreadPool.h | 2 +- .../BoundingRegionWithLooseFittingHeights.cpp | 2 +- CesiumGeospatial/src/Projection.cpp | 21 +++++------ CesiumGltfReader/src/GltfReader.cpp | 4 +-- .../include/CesiumGltf/WriteGLTFCallback.h | 3 +- .../include/CesiumIonClient/Connection.h | 11 +++--- .../CesiumJsonReader/ArrayJsonHandler.h | 4 +-- .../src/IgnoreValueJsonHandler.cpp | 14 ++++---- CesiumJsonReader/src/JsonReader.cpp | 9 +++-- CesiumJsonReader/src/ObjectJsonHandler.cpp | 8 ++--- CesiumJsonReader/src/StringJsonHandler.cpp | 2 +- .../include/CesiumUtility/IntrusivePointer.h | 2 +- .../include/CesiumUtility/JsonValue.h | 35 ++++++++++--------- CesiumUtility/include/CesiumUtility/Math.h | 4 +-- .../include/CesiumUtility/SpanHelper.h | 2 +- 25 files changed, 112 insertions(+), 91 deletions(-) diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/CreditSystem.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/CreditSystem.h index 538cc9c48..eb83bd778 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/CreditSystem.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/CreditSystem.h @@ -17,12 +17,14 @@ struct CESIUM3DTILESSELECTION_API Credit { /** * @brief Returns `true` if two credit objects have the same ID. */ - bool operator==(const Credit& rhs) const { return this->id == rhs.id; } + bool operator==(const Credit& rhs) const noexcept { + return this->id == rhs.id; + } private: size_t id; - Credit(size_t id_) { id = id_; } + Credit(size_t id_) noexcept { id = id_; } friend class CreditSystem; }; @@ -61,7 +63,7 @@ class CESIUM3DTILESSELECTION_API CreditSystem final { /** * @brief Get the credits to show this frame. */ - const std::vector& getCreditsToShowThisFrame() const { + const std::vector& getCreditsToShowThisFrame() const noexcept { return _creditsToShowThisFrame; } @@ -69,7 +71,8 @@ class CESIUM3DTILESSELECTION_API CreditSystem final { * @brief Get the credits that were shown last frame but should no longer be * shown. */ - const std::vector& getCreditsToNoLongerShowThisFrame() const { + const std::vector& + getCreditsToNoLongerShowThisFrame() const noexcept { return _creditsToNoLongerShowThisFrame; } @@ -88,4 +91,4 @@ class CESIUM3DTILESSELECTION_API CreditSystem final { std::vector _creditsToShowThisFrame; std::vector _creditsToNoLongerShowThisFrame; }; -} // namespace Cesium3DTilesSelection \ No newline at end of file +} // namespace Cesium3DTilesSelection diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlay.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlay.h index 86b92dc9e..ea1933592 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlay.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlay.h @@ -64,15 +64,17 @@ class RasterOverlay { /** * @brief Gets the name of this overlay. */ - const std::string& getName() const { return this->_name; } + const std::string& getName() const noexcept { return this->_name; } /** * @brief Gets options for this overlay. */ - RasterOverlayOptions& getOptions() { return this->_options; } + RasterOverlayOptions& getOptions() noexcept { return this->_options; } /** @copydoc getOptions */ - const RasterOverlayOptions& getOptions() const { return this->_options; } + const RasterOverlayOptions& getOptions() const noexcept { + return this->_options; + } /** * @brief Gets the tile provider for this overlay. diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayTile.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayTile.h index 2e65bfbb5..15ee3e4a9 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayTile.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayTile.h @@ -132,7 +132,7 @@ class RasterOverlayTile final { * @brief Returns the {@link CesiumGeometry::Rectangle} that defines the bounds * of this tile in the raster overlay's projected coordinates. */ - const CesiumGeometry::Rectangle& getRectangle() const { + const CesiumGeometry::Rectangle& getRectangle() const noexcept { return this->_rectangle; } @@ -143,7 +143,9 @@ class RasterOverlayTile final { * This is used to control which content (how highly detailed) the * {@link RasterOverlayTileProvider} uses within the bounds of this tile. */ - double getTargetGeometricError() const { return this->_targetGeometricError; } + double getTargetGeometricError() const noexcept { + return this->_targetGeometricError; + } /** * @brief Returns the current {@link LoadState}. @@ -183,14 +185,16 @@ class RasterOverlayTile final { /** * @brief Returns the renderer resources that have been created for this tile. */ - void* getRendererResources() const { return this->_pRendererResources; } + void* getRendererResources() const noexcept { + return this->_pRendererResources; + } /** * @brief Set the renderer resources for this tile. * * This function is not supposed to be called by clients. */ - void setRendererResources(void* pValue) { + void setRendererResources(void* pValue) noexcept { this->_pRendererResources = pValue; } @@ -198,7 +202,7 @@ class RasterOverlayTile final { * @brief Determines if more detailed data is available for the spatial area * covered by this tile. */ - MoreDetailAvailable isMoreDetailAvailable() const { + MoreDetailAvailable isMoreDetailAvailable() const noexcept { return this->_moreDetailAvailable; } diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h index 140fc96e9..3deab8ebc 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h @@ -540,7 +540,7 @@ class CESIUM3DTILESSELECTION_API Tileset final { */ double priority; - bool operator<(const LoadRecord& rhs) const { + bool operator<(const LoadRecord& rhs) const noexcept { return this->priority < rhs.priority; } }; diff --git a/Cesium3DTilesSelection/src/BoundingVolume.cpp b/Cesium3DTilesSelection/src/BoundingVolume.cpp index a50f24487..86a71330c 100644 --- a/Cesium3DTilesSelection/src/BoundingVolume.cpp +++ b/Cesium3DTilesSelection/src/BoundingVolume.cpp @@ -17,7 +17,7 @@ BoundingVolume transformBoundingVolume( return OrientedBoundingBox(center, halfAxes); } - BoundingVolume operator()(const BoundingRegion& boundingRegion) { + BoundingVolume operator()(const BoundingRegion& boundingRegion) noexcept { // Regions are not transformed. return boundingRegion; } @@ -35,8 +35,8 @@ BoundingVolume transformBoundingVolume( return BoundingSphere(center, boundingSphere.getRadius() * uniformScale); } - BoundingVolume - operator()(const BoundingRegionWithLooseFittingHeights& boundingRegion) { + BoundingVolume operator()( + const BoundingRegionWithLooseFittingHeights& boundingRegion) noexcept { // Regions are not transformed. return boundingRegion; } @@ -47,20 +47,20 @@ BoundingVolume transformBoundingVolume( glm::dvec3 getBoundingVolumeCenter(const BoundingVolume& boundingVolume) { struct Operation { - glm::dvec3 operator()(const OrientedBoundingBox& boundingBox) { + glm::dvec3 operator()(const OrientedBoundingBox& boundingBox) noexcept { return boundingBox.getCenter(); } - glm::dvec3 operator()(const BoundingRegion& boundingRegion) { + glm::dvec3 operator()(const BoundingRegion& boundingRegion) noexcept { return boundingRegion.getBoundingBox().getCenter(); } - glm::dvec3 operator()(const BoundingSphere& boundingSphere) { + glm::dvec3 operator()(const BoundingSphere& boundingSphere) noexcept { return boundingSphere.getCenter(); } - glm::dvec3 - operator()(const BoundingRegionWithLooseFittingHeights& boundingRegion) { + glm::dvec3 operator()( + const BoundingRegionWithLooseFittingHeights& boundingRegion) noexcept { return boundingRegion.getBoundingRegion().getBoundingBox().getCenter(); } }; diff --git a/Cesium3DTilesSelection/src/CreditSystem.cpp b/Cesium3DTilesSelection/src/CreditSystem.cpp index 1edde1b86..08d583932 100644 --- a/Cesium3DTilesSelection/src/CreditSystem.cpp +++ b/Cesium3DTilesSelection/src/CreditSystem.cpp @@ -18,7 +18,7 @@ Credit CreditSystem::createCredit(const std::string& html) { return Credit(_credits.size() - 1); } -const std::string& CreditSystem::getHtml(Credit credit) const { +const std::string& CreditSystem::getHtml(Credit credit) const noexcept { if (credit.id < _credits.size()) { return _credits[credit.id].html; } @@ -50,9 +50,9 @@ void CreditSystem::addCreditToFrame(Credit credit) { _credits[credit.id].lastFrameNumber = _currentFrameNumber; } -void CreditSystem::startNextFrame() { +void CreditSystem::startNextFrame() noexcept { _creditsToNoLongerShowThisFrame.swap(_creditsToShowThisFrame); _creditsToShowThisFrame.clear(); _currentFrameNumber++; } -} // namespace Cesium3DTilesSelection \ No newline at end of file +} // namespace Cesium3DTilesSelection diff --git a/Cesium3DTilesSelection/src/Tile.cpp b/Cesium3DTilesSelection/src/Tile.cpp index c87564e11..506eb0362 100644 --- a/Cesium3DTilesSelection/src/Tile.cpp +++ b/Cesium3DTilesSelection/src/Tile.cpp @@ -110,7 +110,7 @@ bool Tile::isRenderable() const noexcept { return std::all_of( this->_rasterTiles.begin(), this->_rasterTiles.end(), - [](const RasterMappedTo3DTile& rasterTile) { + [](const RasterMappedTo3DTile& rasterTile) noexcept { return rasterTile.getReadyTile() != nullptr; }); } @@ -355,7 +355,7 @@ void Tile::loadContent() { return result; }) - .thenInMainThread([this](LoadResult&& loadResult) { + .thenInMainThread([this](LoadResult&& loadResult) noexcept { this->_pContent = std::move(loadResult.pContent); this->_pRendererResources = loadResult.pRendererResources; this->getTileset()->notifyTileDoneLoading(this); @@ -888,13 +888,13 @@ void Tile::upsampleParent( std::move(pContent), pRendererResources}; }) - .thenInMainThread([this](LoadResult&& loadResult) { + .thenInMainThread([this](LoadResult&& loadResult) noexcept { this->_pContent = std::move(loadResult.pContent); this->_pRendererResources = loadResult.pRendererResources; this->getTileset()->notifyTileDoneLoading(this); this->setState(loadResult.state); }) - .catchInMainThread([this](const std::exception& /*e*/) { + .catchInMainThread([this](const std::exception& /*e*/) noexcept { this->_pContent.reset(); this->_pRendererResources = nullptr; this->getTileset()->notifyTileDoneLoading(this); diff --git a/Cesium3DTilesSelection/src/TileContentFactory.cpp b/Cesium3DTilesSelection/src/TileContentFactory.cpp index b3efcf6ca..ecb542810 100644 --- a/Cesium3DTilesSelection/src/TileContentFactory.cpp +++ b/Cesium3DTilesSelection/src/TileContentFactory.cpp @@ -25,7 +25,7 @@ void TileContentFactory::registerContentType( contentType.begin(), contentType.end(), std::back_inserter(lowercaseContentType), - [](char c) { return static_cast(::tolower(c)); }); + [](char c) noexcept { return static_cast(::tolower(c)); }); TileContentFactory::_loadersByContentType[lowercaseContentType] = pLoader; } diff --git a/CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h b/CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h index 5acccd915..75a9d285d 100644 --- a/CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h +++ b/CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h @@ -9,7 +9,7 @@ namespace Impl { template class ImmediateScheduler { public: explicit ImmediateScheduler(TScheduler* pScheduler) - : _pScheduler(pScheduler) {} + : _pScheduler(pScheduler) noexcept {} void schedule(async::task_run_handle t) { // Are we already in a suitable thread? @@ -47,7 +47,7 @@ template class ImmediateScheduler { return *this; } - void reset() { + void reset() noexcept { if (this->_pScheduler) { std::vector& inSuitable = ImmediateScheduler::getSchedulersCurrentlyDispatching(); @@ -74,7 +74,8 @@ template class ImmediateScheduler { // If a TScheduler instance is found in this thread-local vector, then the // current thread has been dispatched by this scheduler and therefore we can // dispatch immediately. - static std::vector& getSchedulersCurrentlyDispatching() { + static std::vector& + getSchedulersCurrentlyDispatching() noexcept { // We're using a static local here rather than a static field because, on // at least some Linux systems (mine), with Clang 12, in a Debug build, a // thread_local static field causes a SEGFAULT on access. diff --git a/CesiumAsync/include/CesiumAsync/Promise.h b/CesiumAsync/include/CesiumAsync/Promise.h index d52d0f13e..03c0ee4a5 100644 --- a/CesiumAsync/include/CesiumAsync/Promise.h +++ b/CesiumAsync/include/CesiumAsync/Promise.h @@ -58,7 +58,7 @@ template class Promise { Promise( const std::shared_ptr& pSchedulers, const std::shared_ptr>& pEvent) - : _pSchedulers(pSchedulers), _pEvent(pEvent) {} + : _pSchedulers(pSchedulers), _pEvent(pEvent) noexcept {} std::shared_ptr _pSchedulers; std::shared_ptr> _pEvent; @@ -84,7 +84,7 @@ template <> class Promise { Promise( const std::shared_ptr& pSchedulers, const std::shared_ptr>& pEvent) - : _pSchedulers(pSchedulers), _pEvent(pEvent) {} + : _pSchedulers(pSchedulers), _pEvent(pEvent) noexcept {} std::shared_ptr _pSchedulers; std::shared_ptr> _pEvent; diff --git a/CesiumAsync/include/CesiumAsync/ThreadPool.h b/CesiumAsync/include/CesiumAsync/ThreadPool.h index 7ebd33aa4..07a195d23 100644 --- a/CesiumAsync/include/CesiumAsync/ThreadPool.h +++ b/CesiumAsync/include/CesiumAsync/ThreadPool.h @@ -33,7 +33,7 @@ class CESIUMASYNC_API ThreadPool { [pScheduler]() { ThreadPool::_scope = pScheduler->immediate.scope(); }; } - static auto createPostRun() { + static auto createPostRun() noexcept { return []() { ThreadPool::_scope.reset(); }; } diff --git a/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp b/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp index 97bdaa1e8..94c9d9d46 100644 --- a/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp +++ b/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp @@ -3,7 +3,7 @@ namespace CesiumGeospatial { BoundingRegionWithLooseFittingHeights::BoundingRegionWithLooseFittingHeights( - const BoundingRegion& boundingRegion) + const BoundingRegion& boundingRegion) noexcept : _region(boundingRegion) {} double BoundingRegionWithLooseFittingHeights:: diff --git a/CesiumGeospatial/src/Projection.cpp b/CesiumGeospatial/src/Projection.cpp index e2186b99a..25da8d6c3 100644 --- a/CesiumGeospatial/src/Projection.cpp +++ b/CesiumGeospatial/src/Projection.cpp @@ -8,11 +8,11 @@ projectPosition(const Projection& projection, const Cartographic& position) { struct Operation { const Cartographic& position; - glm::dvec3 operator()(const GeographicProjection& geographic) { + glm::dvec3 operator()(const GeographicProjection& geographic) noexcept { return geographic.project(position); } - glm::dvec3 operator()(const WebMercatorProjection& webMercator) { + glm::dvec3 operator()(const WebMercatorProjection& webMercator) noexcept { return webMercator.project(position); } }; @@ -25,11 +25,11 @@ unprojectPosition(const Projection& projection, const glm::dvec3& position) { struct Operation { const glm::dvec3& position; - Cartographic operator()(const GeographicProjection& geographic) { + Cartographic operator()(const GeographicProjection& geographic) noexcept { return geographic.unproject(position); } - Cartographic operator()(const WebMercatorProjection& webMercator) { + Cartographic operator()(const WebMercatorProjection& webMercator) noexcept { return webMercator.unproject(position); } }; @@ -44,12 +44,12 @@ CesiumGeometry::Rectangle projectRectangleSimple( const GlobeRectangle& rectangle; CesiumGeometry::Rectangle - operator()(const GeographicProjection& geographic) { + operator()(const GeographicProjection& geographic) noexcept { return geographic.project(rectangle); } CesiumGeometry::Rectangle - operator()(const WebMercatorProjection& webMercator) { + operator()(const WebMercatorProjection& webMercator) noexcept { return webMercator.project(rectangle); } }; @@ -63,11 +63,12 @@ GlobeRectangle unprojectRectangleSimple( struct Operation { const CesiumGeometry::Rectangle& rectangle; - GlobeRectangle operator()(const GeographicProjection& geographic) { + GlobeRectangle operator()(const GeographicProjection& geographic) noexcept { return geographic.unproject(rectangle); } - GlobeRectangle operator()(const WebMercatorProjection& webMercator) { + GlobeRectangle + operator()(const WebMercatorProjection& webMercator) noexcept { return webMercator.unproject(rectangle); } }; @@ -81,11 +82,11 @@ double computeApproximateConversionFactorToMetersNearPosition( struct Operation { const glm::dvec2& position; - double operator()(const GeographicProjection& /*geographic*/) { + double operator()(const GeographicProjection& /*geographic*/) noexcept { return 1.0; } - double operator()(const WebMercatorProjection& webMercator) { + double operator()(const WebMercatorProjection& webMercator) noexcept { // TODO: is there a better estimate? return glm::cos(webMercator.unproject(position).latitude); } diff --git a/CesiumGltfReader/src/GltfReader.cpp b/CesiumGltfReader/src/GltfReader.cpp index 5fad0e47c..6382f4ed1 100644 --- a/CesiumGltfReader/src/GltfReader.cpp +++ b/CesiumGltfReader/src/GltfReader.cpp @@ -40,7 +40,7 @@ struct ChunkHeader { }; #pragma pack(pop) -bool isBinaryGltf(const gsl::span& data) { +bool isBinaryGltf(const gsl::span& data) noexcept { if (data.size() < sizeof(GlbHeader)) { return false; } @@ -257,7 +257,7 @@ void postprocess( class AnyExtensionJsonHandler : public JsonObjectJsonHandler, public IExtensionJsonHandler { public: - AnyExtensionJsonHandler(const ReaderContext& /* context */) + AnyExtensionJsonHandler(const ReaderContext& /* context */) noexcept : JsonObjectJsonHandler() {} virtual void reset( diff --git a/CesiumGltfWriter/include/CesiumGltf/WriteGLTFCallback.h b/CesiumGltfWriter/include/CesiumGltf/WriteGLTFCallback.h index a093845f8..594bbb81c 100644 --- a/CesiumGltfWriter/include/CesiumGltf/WriteGLTFCallback.h +++ b/CesiumGltfWriter/include/CesiumGltf/WriteGLTFCallback.h @@ -10,5 +10,6 @@ using WriteGLTFCallback = const std::function&)>; /** Default no-op callback for glTF / GLB writing */ -inline void noopGltfWriter(std::string_view, const std::vector&) {} +inline void +noopGltfWriter(std::string_view, const std::vector&) noexcept {} } // namespace CesiumGltf diff --git a/CesiumIonClient/include/CesiumIonClient/Connection.h b/CesiumIonClient/include/CesiumIonClient/Connection.h index f89f1971d..01a4a132a 100644 --- a/CesiumIonClient/include/CesiumIonClient/Connection.h +++ b/CesiumIonClient/include/CesiumIonClient/Connection.h @@ -75,7 +75,7 @@ class CESIUMASYNC_API Connection { /** * @brief Gets the async system used by this connection to do work in threads. */ - const CesiumAsync::AsyncSystem& getAsyncSystem() const { + const CesiumAsync::AsyncSystem& getAsyncSystem() const noexcept { return this->_asyncSystem; } @@ -83,19 +83,22 @@ class CESIUMASYNC_API Connection { * @brief Gets the interface used by this connection to interact with the * Cesium ion REST API. */ - const std::shared_ptr& getAssetAccessor() const { + const std::shared_ptr& + getAssetAccessor() const noexcept { return this->_pAssetAccessor; } /** * @brief Gets the access token used by this connection. */ - const std::string& getAccessToken() const { return this->_accessToken; } + const std::string& getAccessToken() const noexcept { + return this->_accessToken; + } /** * @brief Gets the Cesium ion API base URL. */ - const std::string& getApiUrl() const { return this->_apiUrl; } + const std::string& getApiUrl() const noexcept { return this->_apiUrl; } /** * @brief Retrieves profile information for the access token currently being diff --git a/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h index 352633aaf..b65496479 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h @@ -66,11 +66,11 @@ class CESIUMJSONREADER_API ArrayJsonHandler : public JsonHandler { } virtual IJsonHandler* - readObjectKey(const std::string_view& /*str*/) override { + readObjectKey(const std::string_view& /*str*/) noexcept override { return nullptr; } - virtual IJsonHandler* readObjectEnd() override { return nullptr; } + virtual IJsonHandler* readObjectEnd() noexcept override { return nullptr; } virtual IJsonHandler* readArrayStart() override { if (this->_arrayIsOpen) { diff --git a/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp b/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp index 73856198b..22fb945a5 100644 --- a/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp +++ b/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp @@ -3,7 +3,7 @@ using namespace CesiumJsonReader; -void IgnoreValueJsonHandler::reset(IJsonHandler* pParent) { +void IgnoreValueJsonHandler::reset(IJsonHandler* pParent) noexcept { this->_pParent = pParent; this->_depth = 0; } @@ -41,13 +41,13 @@ IgnoreValueJsonHandler::readString(const std::string_view& /*str*/) { return this->_depth == 0 ? this->parent() : this; } -IJsonHandler* IgnoreValueJsonHandler::readObjectStart() { +IJsonHandler* IgnoreValueJsonHandler::readObjectStart() noexcept { ++this->_depth; return this; } -IJsonHandler* -IgnoreValueJsonHandler::readObjectKey(const std::string_view& /*str*/) { +IJsonHandler* IgnoreValueJsonHandler::readObjectKey( + const std::string_view& /*str*/) noexcept { return this; } @@ -56,7 +56,7 @@ IJsonHandler* IgnoreValueJsonHandler::readObjectEnd() { return this->_depth == 0 ? this->parent() : this; } -IJsonHandler* IgnoreValueJsonHandler::readArrayStart() { +IJsonHandler* IgnoreValueJsonHandler::readArrayStart() noexcept { ++this->_depth; return this; } @@ -73,4 +73,6 @@ void IgnoreValueJsonHandler::reportWarning( this->parent()->reportWarning(warning, std::move(context)); } -IJsonHandler* IgnoreValueJsonHandler::parent() { return this->_pParent; } \ No newline at end of file +IJsonHandler* IgnoreValueJsonHandler::parent() noexcept { + return this->_pParent; +} diff --git a/CesiumJsonReader/src/JsonReader.cpp b/CesiumJsonReader/src/JsonReader.cpp index 997dbae9f..7f9ba3913 100644 --- a/CesiumJsonReader/src/JsonReader.cpp +++ b/CesiumJsonReader/src/JsonReader.cpp @@ -9,7 +9,7 @@ namespace { struct Dispatcher { IJsonHandler* pCurrent; - bool update(IJsonHandler* pNext) { + bool update(IJsonHandler* pNext) noexcept { if (pNext == nullptr) { return false; } @@ -25,7 +25,10 @@ struct Dispatcher { bool Int64(int64_t i) { return update(pCurrent->readInt64(i)); } bool Uint64(uint64_t i) { return update(pCurrent->readUint64(i)); } bool Double(double d) { return update(pCurrent->readDouble(d)); } - bool RawNumber(const char* /* str */, size_t /* length */, bool /* copy */) { + bool RawNumber( + const char* /* str */, + size_t /* length */, + bool /* copy */) noexcept { // This should not be called. assert(false); return false; @@ -112,7 +115,7 @@ void JsonReader::FinalJsonHandler::reportWarning( } void JsonReader::FinalJsonHandler::setInputStream( - rapidjson::MemoryStream* pInputStream) { + rapidjson::MemoryStream* pInputStream) noexcept { this->_pInputStream = pInputStream; } diff --git a/CesiumJsonReader/src/ObjectJsonHandler.cpp b/CesiumJsonReader/src/ObjectJsonHandler.cpp index 4d2694224..ff1937ef2 100644 --- a/CesiumJsonReader/src/ObjectJsonHandler.cpp +++ b/CesiumJsonReader/src/ObjectJsonHandler.cpp @@ -21,9 +21,9 @@ IJsonHandler* ObjectJsonHandler::readObjectEnd() { return this->parent(); } -IJsonHandler* ObjectJsonHandler::StartSubObject() { return nullptr; } +IJsonHandler* ObjectJsonHandler::StartSubObject() noexcept { return nullptr; } -IJsonHandler* ObjectJsonHandler::EndSubObject() { return nullptr; } +IJsonHandler* ObjectJsonHandler::EndSubObject() noexcept { return nullptr; } void ObjectJsonHandler::reportWarning( const std::string& warning, @@ -34,10 +34,10 @@ void ObjectJsonHandler::reportWarning( this->parent()->reportWarning(warning, std::move(context)); } -const char* ObjectJsonHandler::getCurrentKey() const { +const char* ObjectJsonHandler::getCurrentKey() const noexcept { return this->_currentKey; } -void ObjectJsonHandler::setCurrentKey(const char* key) { +void ObjectJsonHandler::setCurrentKey(const char* key) noexcept { this->_currentKey = key; } diff --git a/CesiumJsonReader/src/StringJsonHandler.cpp b/CesiumJsonReader/src/StringJsonHandler.cpp index b988b3adb..81f6c6e20 100644 --- a/CesiumJsonReader/src/StringJsonHandler.cpp +++ b/CesiumJsonReader/src/StringJsonHandler.cpp @@ -10,7 +10,7 @@ void StringJsonHandler::reset(IJsonHandler* pParent, std::string* pString) { this->_pString = pString; } -std::string* StringJsonHandler::getObject() { return this->_pString; } +std::string* StringJsonHandler::getObject() noexcept { return this->_pString; } IJsonHandler* StringJsonHandler::readString(const std::string_view& str) { *this->_pString = str; diff --git a/CesiumUtility/include/CesiumUtility/IntrusivePointer.h b/CesiumUtility/include/CesiumUtility/IntrusivePointer.h index 9e7093556..9fd415ee9 100644 --- a/CesiumUtility/include/CesiumUtility/IntrusivePointer.h +++ b/CesiumUtility/include/CesiumUtility/IntrusivePointer.h @@ -101,7 +101,7 @@ template class IntrusivePointer final { /** * @brief Returns the internal pointer. */ - T* get() const { return this->_p; } + T* get() const noexcept { return this->_p; } /** * @brief Returns `true` if two pointers are equal. diff --git a/CesiumUtility/include/CesiumUtility/JsonValue.h b/CesiumUtility/include/CesiumUtility/JsonValue.h index 52748dc5f..57a1dab22 100644 --- a/CesiumUtility/include/CesiumUtility/JsonValue.h +++ b/CesiumUtility/include/CesiumUtility/JsonValue.h @@ -82,14 +82,14 @@ class CESIUMUTILITY_API JsonValue final { /** * @brief Creates a `null` JSON value. */ - JsonValue(std::nullptr_t) : value(nullptr) {} + JsonValue(std::nullptr_t) noexcept : value(nullptr) {} /** * @brief Creates a `Number` JSON value. * * NaN and ±Infinity are represented as {@link JsonValue::Null}. */ - JsonValue(double v) { + JsonValue(double v) noexcept { if (std::isnan(v) || std::isinf(v)) { value = nullptr; } else { @@ -101,52 +101,52 @@ class CESIUMUTILITY_API JsonValue final { * @brief Creates a `std::int64_t` JSON value (Widening conversion from * std::int8_t). */ - JsonValue(std::int8_t v) : value(static_cast(v)) {} + JsonValue(std::int8_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::uint64_t` JSON value (Widening conversion from * std::uint8_t). */ - JsonValue(std::uint8_t v) : value(static_cast(v)) {} + JsonValue(std::uint8_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::int64_t` JSON value (Widening conversion from * std::int16_t). */ - JsonValue(std::int16_t v) : value(static_cast(v)) {} + JsonValue(std::int16_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::uint64_t` JSON value (Widening conversion from * std::uint16_t). */ - JsonValue(std::uint16_t v) : value(static_cast(v)) {} + JsonValue(std::uint16_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::int64_t` JSON value (Widening conversion from * std::int32_t). */ - JsonValue(std::int32_t v) : value(static_cast(v)) {} + JsonValue(std::int32_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::uint64_t` JSON value (Widening conversion from * std::uint32_t). */ - JsonValue(std::uint32_t v) : value(static_cast(v)) {} + JsonValue(std::uint32_t v) noexcept : value(static_cast(v)) {} /** * @brief Creates a `std::int64_t` JSON value. */ - JsonValue(std::int64_t v) : value(v) {} + JsonValue(std::int64_t v) noexcept : value(v) {} /** * @brief Creates a `std::uint64_t` JSON value. */ - JsonValue(std::uint64_t v) : value(v) {} + JsonValue(std::uint64_t v) noexcept : value(v) {} /** * @brief Creates a `Bool` JSON value. */ - JsonValue(bool v) : value(v) {} + JsonValue(bool v) noexcept : value(v) {} /** * @brief Creates a `String` JSON value. @@ -156,7 +156,7 @@ class CESIUMUTILITY_API JsonValue final { /** * @brief Creates a `String` JSON value. */ - JsonValue(std::string&& v) : value(std::move(v)) {} + JsonValue(std::string&& v) noexcept : value(std::move(v)) {} /** * @brief Creates a `String` JSON value. @@ -181,7 +181,7 @@ class CESIUMUTILITY_API JsonValue final { /** * @brief Creates an `Array` JSON value with the given elements. */ - JsonValue(std::vector&& v) : value(std::move(v)) {} + JsonValue(std::vector&& v) noexcept : value(std::move(v)) {} /** * @brief Creates an JSON value from the given initializer list. @@ -462,7 +462,7 @@ class CESIUMUTILITY_API JsonValue final { * @brief Gets the bool from the value or returns defaultValue * @return The bool or defaultValue if this->value is not a bool. */ - [[nodiscard]] inline bool getBoolOrDefault(bool defaultValue) const { + [[nodiscard]] inline bool getBoolOrDefault(bool defaultValue) const noexcept { const auto* v = std::get_if(&this->value); if (v) { return *v; @@ -489,7 +489,8 @@ class CESIUMUTILITY_API JsonValue final { * @brief Gets the double from the value or returns defaultValue * @return The double or defaultValue if this->value is not a double. */ - [[nodiscard]] inline double getDoubleOrDefault(double defaultValue) const { + [[nodiscard]] inline double + getDoubleOrDefault(double defaultValue) const noexcept { const auto* v = std::get_if(&this->value); if (v) { return *v; @@ -503,7 +504,7 @@ class CESIUMUTILITY_API JsonValue final { * @return The uint64_t or defaultValue if this->value is not a uint64_t. */ [[nodiscard]] inline std::uint64_t - getUint64OrDefault(std::uint64_t defaultValue) const { + getUint64OrDefault(std::uint64_t defaultValue) const noexcept { const auto* v = std::get_if(&this->value); if (v) { return *v; @@ -517,7 +518,7 @@ class CESIUMUTILITY_API JsonValue final { * @return The int64_t or defaultValue if this->value is not a int64_t. */ [[nodiscard]] inline std::int64_t - getInt64OrDefault(std::int64_t defaultValue) const { + getInt64OrDefault(std::int64_t defaultValue) const noexcept { const auto* v = std::get_if(&this->value); if (v) { return *v; diff --git a/CesiumUtility/include/CesiumUtility/Math.h b/CesiumUtility/include/CesiumUtility/Math.h index febe92b29..b5c464deb 100644 --- a/CesiumUtility/include/CesiumUtility/Math.h +++ b/CesiumUtility/include/CesiumUtility/Math.h @@ -406,7 +406,7 @@ class CESIUMUTILITY_API Math final { * lower integer, it is rounded down instead. * @return The rounded value. */ - static double roundUp(double value, double tolerance) { + static double roundUp(double value, double tolerance) noexcept { double up = glm::ceil(value); double down = glm::floor(value); if (value - down < tolerance) { @@ -426,7 +426,7 @@ class CESIUMUTILITY_API Math final { * higher integer, it is rounded up instead. * @return The rounded value. */ - static double roundDown(double value, double tolerance) { + static double roundDown(double value, double tolerance) noexcept { double up = glm::ceil(value); double down = glm::floor(value); if (up - value < tolerance) { diff --git a/CesiumUtility/include/CesiumUtility/SpanHelper.h b/CesiumUtility/include/CesiumUtility/SpanHelper.h index 7d54e283d..84fddffb0 100644 --- a/CesiumUtility/include/CesiumUtility/SpanHelper.h +++ b/CesiumUtility/include/CesiumUtility/SpanHelper.h @@ -10,7 +10,7 @@ namespace CesiumUtility { * carefully */ template -gsl::span reintepretCastSpan(const gsl::span& from) { +gsl::span reintepretCastSpan(const gsl::span& from) noexcept { return gsl::span( reinterpret_cast(from.data()), from.size() * sizeof(From) / sizeof(To));