From e769b8f74afc6ef0ebddc0d536db0752d82985b9 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 7 Oct 2015 14:37:22 +1100 Subject: [PATCH] noise: annotate generators with noexcept --- noise/basis/perlin.hpp | 2 +- noise/basis/perlin.ipp | 2 +- noise/basis/runtime.hpp | 6 +++--- noise/fractal/fbm.hpp | 2 +- noise/fractal/fbm.ipp | 2 +- noise/fractal/runtime.hpp | 6 +++--- noise/lerp.cpp | 10 +++++----- noise/lerp.hpp | 10 +++++----- noise/rand.hpp | 4 ++-- noise/rand/hash.hpp | 4 ++-- noise/rand/hash.ipp | 4 ++-- noise/rand/permute.hpp | 4 ++-- noise/rand/permute.ipp | 4 ++-- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/noise/basis/perlin.hpp b/noise/basis/perlin.hpp index 02935d87..c95c1d84 100644 --- a/noise/basis/perlin.hpp +++ b/noise/basis/perlin.hpp @@ -46,7 +46,7 @@ namespace util { namespace noise { namespace basis { range bounds (void) const; - T operator() (point_t) const; + T operator() (point_t) const noexcept; }; } } } diff --git a/noise/basis/perlin.ipp b/noise/basis/perlin.ipp index 51fbabb9..6ca50e95 100644 --- a/noise/basis/perlin.ipp +++ b/noise/basis/perlin.ipp @@ -45,7 +45,7 @@ namespace util { namespace noise { namespace basis { //------------------------------------------------------------------------- template class L, template class G> T - perlin::operator() (point_t p) const + perlin::operator() (point_t p) const noexcept { // extract integer and fractional parts. be careful to always round down auto p_int = floor (p).template cast (); diff --git a/noise/basis/runtime.hpp b/noise/basis/runtime.hpp index 0a65c5fa..386c79f4 100644 --- a/noise/basis/runtime.hpp +++ b/noise/basis/runtime.hpp @@ -37,7 +37,7 @@ namespace util { namespace noise { namespace basis { runtime& operator= (const runtime&) = delete; // basis functions - T operator () (util::point p) const { return (*m_child) (p); } + T operator () (util::point p) const noexcept { return (*m_child) (p); } range bounds (void) const { return m_child->bounds (); } seed_t seed (void) const { return m_child->seed (); } @@ -46,7 +46,7 @@ namespace util { namespace noise { namespace basis { private: struct base { virtual ~base () = default; - virtual T operator() (util::point) const = 0; + virtual T operator() (util::point) const noexcept = 0; virtual range bounds (void) const = 0; virtual seed_t seed (void) const = 0; virtual seed_t seed (seed_t) = 0; @@ -56,7 +56,7 @@ namespace util { namespace noise { namespace basis { struct child : public base { template child (seed_t _seed, Args&& ...args): data (_seed, std::forward (args)...) { } - virtual T operator() (util::point p) const override { return data (p); } + virtual T operator() (util::point p) const noexcept override { return data (p); } virtual range bounds (void) const override { return data.bounds (); } virtual seed_t seed (void) const override { return data.seed (); } virtual seed_t seed (seed_t _seed) override { return data.seed (_seed); } diff --git a/noise/fractal/fbm.hpp b/noise/fractal/fbm.hpp index 894ee90e..7972f2d7 100644 --- a/noise/fractal/fbm.hpp +++ b/noise/fractal/fbm.hpp @@ -54,7 +54,7 @@ namespace util { namespace noise { namespace fractal { value_t gain); fbm (seed_t); - value_t operator() (point_t) const; + value_t operator() (point_t) const noexcept; }; } } } diff --git a/noise/fractal/fbm.ipp b/noise/fractal/fbm.ipp index 3da70643..6905f952 100644 --- a/noise/fractal/fbm.ipp +++ b/noise/fractal/fbm.ipp @@ -57,7 +57,7 @@ namespace util { namespace noise { namespace fractal { /////////////////////////////////////////////////////////////////////////// template typename fbm::value_t - fbm::operator() (point_t p) const + fbm::operator() (point_t p) const noexcept { value_t total = 0; value_t scale = this->m_invAH; diff --git a/noise/fractal/runtime.hpp b/noise/fractal/runtime.hpp index 138bfa7e..7d729c71 100644 --- a/noise/fractal/runtime.hpp +++ b/noise/fractal/runtime.hpp @@ -36,7 +36,7 @@ namespace util { namespace noise { namespace fractal { runtime& operator= (const runtime&) = delete; // basis functions - value_t operator () (point_t p) const { return (*m_child) (p); } + value_t operator () (point_t p) const noexcept { return (*m_child) (p); } unsigned octaves (void) const { return m_child->octaves (); } unsigned octaves (unsigned _octaves) { return m_child->octaves (_octaves); } @@ -66,7 +66,7 @@ namespace util { namespace noise { namespace fractal { struct base { virtual ~base () = default; - virtual value_t operator() (point_t) = 0; + virtual value_t operator() (point_t) const noexcept = 0; virtual unsigned octaves (void) const = 0; virtual unsigned octaves (unsigned) = 0; @@ -115,7 +115,7 @@ namespace util { namespace noise { namespace fractal { _gain) { ; } - value_t operator() (point_t p) override { return data (p); } + value_t operator() (point_t p) const noexcept override { return data (p); } unsigned octaves (void) const override { return data.octaves (); } unsigned octaves (unsigned _octaves) override { return data.octaves (_octaves); } diff --git a/noise/lerp.cpp b/noise/lerp.cpp index 0e5ba8e7..2b81f12f 100644 --- a/noise/lerp.cpp +++ b/noise/lerp.cpp @@ -31,7 +31,7 @@ using util::lerp::truncate; //----------------------------------------------------------------------------- template T -truncate::operator() (T a, T, T weight) +truncate::operator() (T a, T, T weight) noexcept { static_assert (std::is_floating_point::value, "lerp is only defined for floating types"); @@ -49,7 +49,7 @@ template struct util::lerp::truncate; //----------------------------------------------------------------------------- template T -linear::operator() (T a, T b, T weight) +linear::operator() (T a, T b, T weight) noexcept { static_assert (std::is_floating_point::value, "lerp is only defined for floating types"); @@ -65,7 +65,7 @@ template struct util::lerp::linear; //----------------------------------------------------------------------------- template T -cosine::operator() (T a, T b, T weight) +cosine::operator() (T a, T b, T weight) noexcept { static_assert (std::is_floating_point::value, "lerp is only defined for floating types"); @@ -82,7 +82,7 @@ template struct util::lerp::cosine; //----------------------------------------------------------------------------- template T -cubic::operator() (T a, T b, T weight) +cubic::operator() (T a, T b, T weight) noexcept { static_assert (std::is_floating_point::value, "lerp is only defined for floating types"); @@ -100,7 +100,7 @@ template struct util::lerp::cubic; //----------------------------------------------------------------------------- template T -quintic::operator() (T a, T b, T weight) +quintic::operator() (T a, T b, T weight) noexcept { static_assert (std::is_floating_point::value, "lerp is only defined for floating types"); diff --git a/noise/lerp.hpp b/noise/lerp.hpp index 36a465cc..be7d11de 100644 --- a/noise/lerp.hpp +++ b/noise/lerp.hpp @@ -18,11 +18,11 @@ #define __UTIL_NOISE_LERP_HPP namespace util { namespace lerp { - template struct linear { T operator() (T, T, T weight); }; - template struct cosine { T operator() (T, T, T weight); }; - template struct cubic { T operator() (T, T, T weight); }; - template struct quintic { T operator() (T, T, T weight); }; - template struct truncate { T operator() (T, T, T weight); }; + template struct linear { T operator() (T, T, T weight) noexcept; }; + template struct cosine { T operator() (T, T, T weight) noexcept; }; + template struct cubic { T operator() (T, T, T weight) noexcept; }; + template struct quintic { T operator() (T, T, T weight) noexcept; }; + template struct truncate { T operator() (T, T, T weight) noexcept; }; } } #endif diff --git a/noise/rand.hpp b/noise/rand.hpp index e017a9d3..d7c6462a 100644 --- a/noise/rand.hpp +++ b/noise/rand.hpp @@ -35,7 +35,7 @@ namespace util { namespace noise { namespace rand { template class Q > U - scalar (uint64_t seed, Q value) + scalar (uint64_t seed, Q value) noexcept { #if 1 return permute::scalar (seed, value); @@ -53,7 +53,7 @@ namespace util { namespace noise { namespace rand { template class Q > R - coord (uint64_t seed, Q value) + coord (uint64_t seed, Q value) noexcept { #if 1 return permute::coord (seed, value); diff --git a/noise/rand/hash.hpp b/noise/rand/hash.hpp index 1aed7e08..03f9cf70 100644 --- a/noise/rand/hash.hpp +++ b/noise/rand/hash.hpp @@ -29,7 +29,7 @@ namespace util { namespace noise { namespace rand { template class Q > static U - scalar (uint64_t seed, Q value); + scalar (uint64_t seed, Q value) noexcept; /// generate a coordinate type with uniform random components in the range [0, 1] template < @@ -40,7 +40,7 @@ namespace util { namespace noise { namespace rand { template class Q > static R - coord (uint64_t seed, Q value); + coord (uint64_t seed, Q value) noexcept; }; } } } diff --git a/noise/rand/hash.ipp b/noise/rand/hash.ipp index 4cf60112..853ad8ac 100644 --- a/noise/rand/hash.ipp +++ b/noise/rand/hash.ipp @@ -30,7 +30,7 @@ namespace util { namespace noise { namespace rand { template class Q > U - hash::scalar (uint64_t seed, Q query) + hash::scalar (uint64_t seed, Q query) noexcept { constexpr decltype(seed) BITS = 0xFFFF; static_assert (std::is_integral::value, @@ -53,7 +53,7 @@ namespace util { namespace noise { namespace rand { template class Q > R - hash::coord (uint64_t seed, Q query) + hash::coord (uint64_t seed, Q query) noexcept { constexpr decltype(seed) PERTURB = 0x96c39996c36c36c3; constexpr decltype(seed) BITS = 0xFFFF; diff --git a/noise/rand/permute.hpp b/noise/rand/permute.hpp index fe723098..672a17c0 100644 --- a/noise/rand/permute.hpp +++ b/noise/rand/permute.hpp @@ -31,7 +31,7 @@ namespace util { namespace noise { namespace rand { template class Q > static U - scalar (uint64_t seed, Q value); + scalar (uint64_t seed, Q value) noexcept; /// generate a coordinate type with uniform random components in the range [0, 1] template < @@ -42,7 +42,7 @@ namespace util { namespace noise { namespace rand { template class Q > static R - coord (uint64_t seed, Q value); + coord (uint64_t seed, Q value) noexcept; private: static const std::array PERMUTE; diff --git a/noise/rand/permute.ipp b/noise/rand/permute.ipp index 5891a017..a8e9b84f 100644 --- a/noise/rand/permute.ipp +++ b/noise/rand/permute.ipp @@ -8,7 +8,7 @@ namespace util { namespace noise { namespace rand { template class Q > U - permute::scalar (uint64_t seed, Q query) + permute::scalar (uint64_t seed, Q query) noexcept { size_t idx = PERMUTE[seed&0xff]; @@ -26,7 +26,7 @@ namespace util { namespace noise { namespace rand { template class Q > R - permute::coord (uint64_t seed, Q query) + permute::coord (uint64_t seed, Q query) noexcept { auto accum = seed; for (auto q: query) {