noise: annotate generators with noexcept

This commit is contained in:
Danny Robson 2015-10-07 14:37:22 +11:00
parent f0f1522307
commit e769b8f74a
13 changed files with 30 additions and 30 deletions

View File

@ -46,7 +46,7 @@ namespace util { namespace noise { namespace basis {
range<T> bounds (void) const;
T operator() (point_t) const;
T operator() (point_t) const noexcept;
};
} } }

View File

@ -45,7 +45,7 @@ namespace util { namespace noise { namespace basis {
//-------------------------------------------------------------------------
template <size_t S, typename T, template <typename> class L, template <size_t,typename> class G>
T
perlin<S,T,L,G>::operator() (point_t p) const
perlin<S,T,L,G>::operator() (point_t p) const noexcept
{
// extract integer and fractional parts. be careful to always round down
auto p_int = floor (p).template cast<intmax_t> ();

View File

@ -37,7 +37,7 @@ namespace util { namespace noise { namespace basis {
runtime& operator= (const runtime&) = delete;
// basis functions
T operator () (util::point<S,T> p) const { return (*m_child) (p); }
T operator () (util::point<S,T> p) const noexcept { return (*m_child) (p); }
range<T> 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<S,T>) const = 0;
virtual T operator() (util::point<S,T>) const noexcept = 0;
virtual range<T> 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 <typename ...Args>
child (seed_t _seed, Args&& ...args): data (_seed, std::forward<Args> (args)...) { }
virtual T operator() (util::point<S,T> p) const override { return data (p); }
virtual T operator() (util::point<S,T> p) const noexcept override { return data (p); }
virtual range<T> 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); }

View File

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

View File

@ -57,7 +57,7 @@ namespace util { namespace noise { namespace fractal {
///////////////////////////////////////////////////////////////////////////
template <class B>
typename fbm<B>::value_t
fbm<B>::operator() (point_t p) const
fbm<B>::operator() (point_t p) const noexcept
{
value_t total = 0;
value_t scale = this->m_invAH;

View File

@ -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); }

View File

@ -31,7 +31,7 @@ using util::lerp::truncate;
//-----------------------------------------------------------------------------
template <typename T>
T
truncate<T>::operator() (T a, T, T weight)
truncate<T>::operator() (T a, T, T weight) noexcept
{
static_assert (std::is_floating_point<T>::value,
"lerp is only defined for floating types");
@ -49,7 +49,7 @@ template struct util::lerp::truncate<double>;
//-----------------------------------------------------------------------------
template <typename T>
T
linear<T>::operator() (T a, T b, T weight)
linear<T>::operator() (T a, T b, T weight) noexcept
{
static_assert (std::is_floating_point<T>::value,
"lerp is only defined for floating types");
@ -65,7 +65,7 @@ template struct util::lerp::linear<double>;
//-----------------------------------------------------------------------------
template <typename T>
T
cosine<T>::operator() (T a, T b, T weight)
cosine<T>::operator() (T a, T b, T weight) noexcept
{
static_assert (std::is_floating_point<T>::value,
"lerp is only defined for floating types");
@ -82,7 +82,7 @@ template struct util::lerp::cosine<double>;
//-----------------------------------------------------------------------------
template <typename T>
T
cubic<T>::operator() (T a, T b, T weight)
cubic<T>::operator() (T a, T b, T weight) noexcept
{
static_assert (std::is_floating_point<T>::value,
"lerp is only defined for floating types");
@ -100,7 +100,7 @@ template struct util::lerp::cubic<double>;
//-----------------------------------------------------------------------------
template <typename T>
T
quintic<T>::operator() (T a, T b, T weight)
quintic<T>::operator() (T a, T b, T weight) noexcept
{
static_assert (std::is_floating_point<T>::value,
"lerp is only defined for floating types");

View File

@ -18,11 +18,11 @@
#define __UTIL_NOISE_LERP_HPP
namespace util { namespace lerp {
template <typename T> struct linear { T operator() (T, T, T weight); };
template <typename T> struct cosine { T operator() (T, T, T weight); };
template <typename T> struct cubic { T operator() (T, T, T weight); };
template <typename T> struct quintic { T operator() (T, T, T weight); };
template <typename T> struct truncate { T operator() (T, T, T weight); };
template <typename T> struct linear { T operator() (T, T, T weight) noexcept; };
template <typename T> struct cosine { T operator() (T, T, T weight) noexcept; };
template <typename T> struct cubic { T operator() (T, T, T weight) noexcept; };
template <typename T> struct quintic { T operator() (T, T, T weight) noexcept; };
template <typename T> struct truncate { T operator() (T, T, T weight) noexcept; };
} }
#endif

View File

@ -35,7 +35,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
U
scalar (uint64_t seed, Q<S,T> value)
scalar (uint64_t seed, Q<S,T> value) noexcept
{
#if 1
return permute::scalar<U> (seed, value);
@ -53,7 +53,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
R<S,U>
coord (uint64_t seed, Q<S,T> value)
coord (uint64_t seed, Q<S,T> value) noexcept
{
#if 1
return permute::coord<R,U,S,T,Q> (seed, value);

View File

@ -29,7 +29,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
static U
scalar (uint64_t seed, Q<S,T> value);
scalar (uint64_t seed, Q<S,T> 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 <size_t,typename> class Q
>
static R<S,U>
coord (uint64_t seed, Q<S,T> value);
coord (uint64_t seed, Q<S,T> value) noexcept;
};
} } }

View File

@ -30,7 +30,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
U
hash::scalar (uint64_t seed, Q<S,T> query)
hash::scalar (uint64_t seed, Q<S,T> query) noexcept
{
constexpr decltype(seed) BITS = 0xFFFF;
static_assert (std::is_integral<T>::value,
@ -53,7 +53,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
R<S,U>
hash::coord (uint64_t seed, Q<S,T> query)
hash::coord (uint64_t seed, Q<S,T> query) noexcept
{
constexpr decltype(seed) PERTURB = 0x96c39996c36c36c3;
constexpr decltype(seed) BITS = 0xFFFF;

View File

@ -31,7 +31,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
static U
scalar (uint64_t seed, Q<S,T> value);
scalar (uint64_t seed, Q<S,T> 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 <size_t,typename> class Q
>
static R<S,U>
coord (uint64_t seed, Q<S,T> value);
coord (uint64_t seed, Q<S,T> value) noexcept;
private:
static const std::array<uint8_t, 256> PERMUTE;

View File

@ -8,7 +8,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
U
permute::scalar (uint64_t seed, Q<S,T> query)
permute::scalar (uint64_t seed, Q<S,T> query) noexcept
{
size_t idx = PERMUTE[seed&0xff];
@ -26,7 +26,7 @@ namespace util { namespace noise { namespace rand {
template <size_t,typename> class Q
>
R<S,U>
permute::coord (uint64_t seed, Q<S,T> query)
permute::coord (uint64_t seed, Q<S,T> query) noexcept
{
auto accum = seed;
for (auto q: query) {