Skip to content

Commit

Permalink
Added missing noexcept specifiers
Browse files Browse the repository at this point in the history
Reported as "C26440 Function ... can be declared noexcept"
  • Loading branch information
javagl committed Sep 14, 2021
1 parent fc3f11d commit 97a2757
Show file tree
Hide file tree
Showing 25 changed files with 112 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -61,15 +63,16 @@ class CESIUM3DTILESSELECTION_API CreditSystem final {
/**
* @brief Get the credits to show this frame.
*/
const std::vector<Credit>& getCreditsToShowThisFrame() const {
const std::vector<Credit>& getCreditsToShowThisFrame() const noexcept {
return _creditsToShowThisFrame;
}

/**
* @brief Get the credits that were shown last frame but should no longer be
* shown.
*/
const std::vector<Credit>& getCreditsToNoLongerShowThisFrame() const {
const std::vector<Credit>&
getCreditsToNoLongerShowThisFrame() const noexcept {
return _creditsToNoLongerShowThisFrame;
}

Expand All @@ -88,4 +91,4 @@ class CESIUM3DTILESSELECTION_API CreditSystem final {
std::vector<Credit> _creditsToShowThisFrame;
std::vector<Credit> _creditsToNoLongerShowThisFrame;
};
} // namespace Cesium3DTilesSelection
} // namespace Cesium3DTilesSelection
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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}.
Expand Down Expand Up @@ -183,22 +185,24 @@ 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;
}

/**
* @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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
16 changes: 8 additions & 8 deletions Cesium3DTilesSelection/src/BoundingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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();
}
};
Expand Down
6 changes: 3 additions & 3 deletions Cesium3DTilesSelection/src/CreditSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
} // namespace Cesium3DTilesSelection
8 changes: 4 additions & 4 deletions Cesium3DTilesSelection/src/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Cesium3DTilesSelection/src/TileContentFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void TileContentFactory::registerContentType(
contentType.begin(),
contentType.end(),
std::back_inserter(lowercaseContentType),
[](char c) { return static_cast<char>(::tolower(c)); });
[](char c) noexcept { return static_cast<char>(::tolower(c)); });
TileContentFactory::_loadersByContentType[lowercaseContentType] = pLoader;
}

Expand Down
7 changes: 4 additions & 3 deletions CesiumAsync/include/CesiumAsync/Impl/ImmediateScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Impl {
template <typename TScheduler> 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?
Expand Down Expand Up @@ -47,7 +47,7 @@ template <typename TScheduler> class ImmediateScheduler {
return *this;
}

void reset() {
void reset() noexcept {
if (this->_pScheduler) {
std::vector<TScheduler*>& inSuitable =
ImmediateScheduler<TScheduler>::getSchedulersCurrentlyDispatching();
Expand All @@ -74,7 +74,8 @@ template <typename TScheduler> 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<TScheduler*>& getSchedulersCurrentlyDispatching() {
static std::vector<TScheduler*>&
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.
Expand Down
4 changes: 2 additions & 2 deletions CesiumAsync/include/CesiumAsync/Promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ template <typename T> class Promise {
Promise(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<async::event_task<T>>& pEvent)
: _pSchedulers(pSchedulers), _pEvent(pEvent) {}
: _pSchedulers(pSchedulers), _pEvent(pEvent) noexcept {}

std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<async::event_task<T>> _pEvent;
Expand All @@ -84,7 +84,7 @@ template <> class Promise<void> {
Promise(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<async::event_task<void>>& pEvent)
: _pSchedulers(pSchedulers), _pEvent(pEvent) {}
: _pSchedulers(pSchedulers), _pEvent(pEvent) noexcept {}

std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<async::event_task<void>> _pEvent;
Expand Down
2 changes: 1 addition & 1 deletion CesiumAsync/include/CesiumAsync/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace CesiumGeospatial {

BoundingRegionWithLooseFittingHeights::BoundingRegionWithLooseFittingHeights(
const BoundingRegion& boundingRegion)
const BoundingRegion& boundingRegion) noexcept
: _region(boundingRegion) {}

double BoundingRegionWithLooseFittingHeights::
Expand Down
21 changes: 11 additions & 10 deletions CesiumGeospatial/src/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand All @@ -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);
}
};
Expand All @@ -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);
}
};
Expand All @@ -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);
}
};
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions CesiumGltfReader/src/GltfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ChunkHeader {
};
#pragma pack(pop)

bool isBinaryGltf(const gsl::span<const std::byte>& data) {
bool isBinaryGltf(const gsl::span<const std::byte>& data) noexcept {
if (data.size() < sizeof(GlbHeader)) {
return false;
}
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion CesiumGltfWriter/include/CesiumGltf/WriteGLTFCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ using WriteGLTFCallback =
const std::function<void(std::string_view, const std::vector<std::byte>&)>;

/** Default no-op callback for glTF / GLB writing */
inline void noopGltfWriter(std::string_view, const std::vector<std::byte>&) {}
inline void
noopGltfWriter(std::string_view, const std::vector<std::byte>&) noexcept {}
} // namespace CesiumGltf
Loading

0 comments on commit 97a2757

Please sign in to comment.