Skip to content

Commit

Permalink
throw() -> noexcept
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Jan 29, 2018
1 parent ef830f9 commit 87e7a0b
Show file tree
Hide file tree
Showing 47 changed files with 236 additions and 233 deletions.
14 changes: 7 additions & 7 deletions Externals/NVTT/src/nvcore/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ namespace nv

// Override new/delete

inline void * operator new (size_t size) throw()
inline void * operator new (size_t size) noexcept
{
return nv::mem::malloc(size);
}

inline void operator delete (void *p) throw()
inline void operator delete (void *p) noexcept
{
nv::mem::free(p);
}

inline void * operator new [] (size_t size) throw()
inline void * operator new [] (size_t size) noexcept
{
return nv::mem::malloc(size);
}

inline void operator delete [] (void * p) throw()
inline void operator delete [] (void * p) noexcept
{
nv::mem::free(p);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ void* operator new(std::size_t sz) throw (std::bad_alloc)
gNewCounter++;
return result;
}
void operator delete(void* p) throw()
void operator delete(void* p) noexcept
{
if (p == NULL)
return;
Expand All @@ -150,7 +150,7 @@ void operator delete(void* p) throw()
/* These are the 'nothrow' versions of the above operators.
The system version will try to call a std::new_handler if they
fail, but your overriding versions are not required to do this. */
void* operator new(std::size_t sz, const std::nothrow_t&) throw()
void* operator new(std::size_t sz, const std::nothrow_t&) noexcept
{
try {
void * result = ::operator new (sz); // calls our overridden operator new
Expand All @@ -159,7 +159,7 @@ void* operator new(std::size_t sz, const std::nothrow_t&) throw()
return NULL;
}
}
void operator delete(void* p, const std::nothrow_t&) throw()
void operator delete(void* p, const std::nothrow_t&) noexcept
{
::operator delete (p);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrMiscMath/quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ template Dquaternion& Dquaternion::set(const _matrix<double>& M);
// quaternion non-member functions

/* Commented out, since it's currently unused (only use is commented out in xrPhysics)
void twoq_2w(const Fquaternion& q1, const Fquaternion& q2, float dt, Fvector& w) throw()
void twoq_2w(const Fquaternion& q1, const Fquaternion& q2, float dt, Fvector& w) noexcept
{
//
// w= 2/dt*arccos(q1.w*q2.w+ q1.v.dotproduct(q2.v))
Expand Down
2 changes: 1 addition & 1 deletion src/xrCDB/xrCDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class XRCDB_API MODEL : Noncopyable
u32 memory();

private:
void syncronize_impl() const throw();
void syncronize_impl() const;
};

// Collider result
Expand Down
4 changes: 2 additions & 2 deletions src/xrCommon/math_funcs_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ inline double _cos(double x) { return cos(x); }
inline bool fsimilar(float a, float b, float cmp = EPS) { return _abs(a-b)<cmp; }
inline bool dsimilar(double a, double b, double cmp = EPS) { return _abs(a-b)<cmp; }

inline bool fis_zero(float val, float cmp = EPS_S) throw() { return _abs(val) < cmp; }
inline bool dis_zero(double val, double cmp = EPS_S) throw() { return _abs(val) < cmp; }
inline bool fis_zero(float val, float cmp = EPS_S) noexcept { return _abs(val) < cmp; }
inline bool dis_zero(double val, double cmp = EPS_S) noexcept { return _abs(val) < cmp; }

// degree to radians and vice-versa
ICF float deg2rad(float val) { return val*M_PI / 180; }
Expand Down
12 changes: 6 additions & 6 deletions src/xrCore/Threading/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include "Event.hpp"
#include <windows.h>

Event::Event() { handle = (void*)CreateEvent(NULL, FALSE, FALSE, NULL); }
Event::~Event() { CloseHandle(handle); }
void Event::Reset() { ResetEvent(handle); }
void Event::Set() { SetEvent(handle); }
void Event::Wait() const { WaitForSingleObject(handle, INFINITE); }
bool Event::Wait(u32 millisecondsTimeout) const
Event::Event() noexcept { handle = (void*)CreateEvent(NULL, FALSE, FALSE, NULL); }
Event::~Event() noexcept { CloseHandle(handle); }
void Event::Reset() noexcept { ResetEvent(handle); }
void Event::Set() noexcept { SetEvent(handle); }
void Event::Wait() const noexcept { WaitForSingleObject(handle, INFINITE); }
bool Event::Wait(u32 millisecondsTimeout) const noexcept
{
return WaitForSingleObject(handle, millisecondsTimeout) != WAIT_TIMEOUT;
}
14 changes: 7 additions & 7 deletions src/xrCore/Threading/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class XRCORE_API Event
void* handle;

public:
Event() throw();
~Event() throw();
Event() noexcept;
~Event() noexcept;

// Reset the event to the unsignalled state.
void Reset() throw();
void Reset() noexcept;
// Set the event to the signalled state.
void Set() throw();
void Set() noexcept;
// Wait indefinitely for the object to become signalled.
void Wait() const throw();
void Wait() const noexcept;
// Wait, with a time limit, for the object to become signalled.
bool Wait(u32 millisecondsTimeout) const throw();
bool Wait(u32 millisecondsTimeout) const noexcept;

void* GetHandle() const throw() { return handle; }
void* GetHandle() const noexcept { return handle; }
};
76 changes: 38 additions & 38 deletions src/xrCore/_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ IC s32 clamp_to_8bit(const s32 val) throw()

// XXX: maybe make functions constexpr
// maps unsigned 8 bits/channel to D3DCOLOR
ICF u32 color_argb(u32 a, u32 r, u32 g, u32 b) throw()
ICF u32 color_argb(u32 a, u32 r, u32 g, u32 b) noexcept
{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
ICF u32 color_rgba(u32 r, u32 g, u32 b, u32 a) throw()
ICF u32 color_rgba(u32 r, u32 g, u32 b, u32 a) noexcept
{ return color_argb(a, r, g, b); }
ICF u32 color_argb_f(f32 a, f32 r, f32 g, f32 b) throw()
ICF u32 color_argb_f(f32 a, f32 r, f32 g, f32 b) noexcept
{
#if 0
s32 _r = clampr(iFloor(r*255.f), 0, 255);
Expand All @@ -34,13 +34,13 @@ ICF u32 color_argb_f(f32 a, f32 r, f32 g, f32 b) throw()
#endif
return color_argb(_a, _r, _g, _b);
}
ICF u32 color_rgba_f(f32 r, f32 g, f32 b, f32 a) throw()
ICF u32 color_rgba_f(f32 r, f32 g, f32 b, f32 a) noexcept
{ return color_argb_f(a, r, g, b); }
ICF u32 color_xrgb(u32 r, u32 g, u32 b) { return color_argb(0xff, r, g, b); }
ICF u32 color_get_R(u32 rgba) throw() { return ((rgba >> 16) & 0xff); }
ICF u32 color_get_G(u32 rgba) throw() { return ((rgba >> 8) & 0xff); }
ICF u32 color_get_B(u32 rgba) throw() { return (rgba & 0xff); }
ICF u32 color_get_A(u32 rgba) throw() { return (rgba >> 24); }
ICF u32 color_get_R(u32 rgba) noexcept { return ((rgba >> 16) & 0xff); }
ICF u32 color_get_G(u32 rgba) noexcept { return ((rgba >> 8) & 0xff); }
ICF u32 color_get_B(u32 rgba) noexcept { return (rgba & 0xff); }
ICF u32 color_get_A(u32 rgba) noexcept { return (rgba >> 24); }
ICF u32 subst_alpha(u32 rgba, u32 a) { return (rgba & ~color_rgba(0, 0, 0, 0xff)) | color_rgba(0, 0, 0, a); }
ICF u32 bgr2rgb(u32 bgr) { return color_rgba(color_get_B(bgr), color_get_G(bgr), color_get_R(bgr), 0); }
ICF u32 rgb2bgr(u32 rgb) { return bgr2rgb(rgb); }
Expand All @@ -49,7 +49,7 @@ struct Fcolor
{
float r, g, b, a;

Fcolor& set(u32 dw) throw()
Fcolor& set(u32 dw) noexcept
{
const float f = float(1.0) / float(255.0);
a = f * float((dw >> 24) & 0xff);
Expand All @@ -66,16 +66,16 @@ struct Fcolor
a = _a;
return *this;
};
Fcolor& set(const Fcolor& rhs) throw()
Fcolor& set(const Fcolor& rhs) noexcept
{
r = rhs.r;
g = rhs.g;
b = rhs.b;
a = rhs.a;
return *this;
}
u32 get() const throw() { return color_rgba_f(r, g, b, a); }
u32 get_windows() const throw() // Get color as a Windows DWORD value.
u32 get() const noexcept { return color_rgba_f(r, g, b, a); }
u32 get_windows() const noexcept // Get color as a Windows DWORD value.
{
u8 _a, _r, _g, _b;
_a = u8(a*255.f);
Expand All @@ -84,7 +84,7 @@ struct Fcolor
_b = u8(b*255.f);
return (u32)(_a << 24) | (_b << 16) | (_g << 8) | _r;
}
Fcolor& set_windows(u32 dw) throw() // Set color from a Windows DWORD color value.
Fcolor& set_windows(u32 dw) noexcept // Set color from a Windows DWORD color value.
{
const float f = 1.0f / 255.0f;
a = f * (float)(u8)(dw >> 24);
Expand All @@ -93,21 +93,21 @@ struct Fcolor
r = f * (float)(u8)(dw >> 0);
return *this;
}
Fcolor& adjust_contrast(float f) throw() // >1 - contrast will be increased
Fcolor& adjust_contrast(float f) noexcept // >1 - contrast will be increased
{
r = 0.5f + f * (r - 0.5f);
g = 0.5f + f * (g - 0.5f);
b = 0.5f + f * (b - 0.5f);
return *this;
}
Fcolor& adjust_contrast(const Fcolor& in, float f) throw() // >1 - contrast will be increased
Fcolor& adjust_contrast(const Fcolor& in, float f) noexcept // >1 - contrast will be increased
{
r = 0.5f + f * (in.r - 0.5f);
g = 0.5f + f * (in.g - 0.5f);
b = 0.5f + f * (in.b - 0.5f);
return *this;
}
Fcolor& adjust_saturation(float s) throw()
Fcolor& adjust_saturation(float s) noexcept
{
// Approximate values for each component's contribution to luminance.
// Based upon the NTSC standard described in ITU-R Recommendation BT.709.
Expand All @@ -117,7 +117,7 @@ struct Fcolor
b = grey + s * (b - grey);
return *this;
}
Fcolor& adjust_saturation(const Fcolor& in, float s) throw()
Fcolor& adjust_saturation(const Fcolor& in, float s) noexcept
{
// Approximate values for each component's contribution to luminance.
// Based upon the NTSC standard described in ITU-R Recommendation BT.709.
Expand All @@ -127,31 +127,31 @@ struct Fcolor
b = grey + s * (in.b - grey);
return *this;
}
Fcolor& modulate(Fcolor& in) throw() { r *= in.r; g *= in.g; b *= in.b; a *= in.a; return *this; }
Fcolor& modulate(const Fcolor& in1, const Fcolor& in2) throw() { r = in1.r*in2.r; g = in1.g*in2.g; b = in1.b*in2.b; a = in1.a*in2.a; return *this; }
Fcolor& negative(const Fcolor& in) throw() { r = 1.0f - in.r; g = 1.0f - in.g; b = 1.0f - in.b; a = 1.0f - in.a; return *this; }
Fcolor& negative() throw() { r = 1.0f - r; g = 1.0f - g; b = 1.0f - b; a = 1.0f - a; return *this; }
Fcolor& sub_rgb(float s) throw() { r -= s; g -= s; b -= s; return *this; }
Fcolor& add_rgb(float s) throw() { r += s; g += s; b += s; return *this; }
Fcolor& add_rgba(float s) throw() { r += s; g += s; b += s; a += s; return *this; }
Fcolor& mul_rgba(float s) throw() { r *= s; g *= s; b *= s; a *= s; return *this; }
Fcolor& mul_rgb(float s) throw() { r *= s; g *= s; b *= s; return *this; }
Fcolor& mul_rgba(const Fcolor& c, float s) throw() { r = c.r*s; g = c.g*s; b = c.b*s; a = c.a*s; return *this; }
Fcolor& mul_rgb(const Fcolor& c, float s) throw() { r = c.r*s; g = c.g*s; b = c.b*s; return *this; }
Fcolor& modulate(Fcolor& in) noexcept { r *= in.r; g *= in.g; b *= in.b; a *= in.a; return *this; }
Fcolor& modulate(const Fcolor& in1, const Fcolor& in2) noexcept { r = in1.r*in2.r; g = in1.g*in2.g; b = in1.b*in2.b; a = in1.a*in2.a; return *this; }
Fcolor& negative(const Fcolor& in) noexcept { r = 1.0f - in.r; g = 1.0f - in.g; b = 1.0f - in.b; a = 1.0f - in.a; return *this; }
Fcolor& negative() noexcept { r = 1.0f - r; g = 1.0f - g; b = 1.0f - b; a = 1.0f - a; return *this; }
Fcolor& sub_rgb(float s) noexcept { r -= s; g -= s; b -= s; return *this; }
Fcolor& add_rgb(float s) noexcept { r += s; g += s; b += s; return *this; }
Fcolor& add_rgba(float s) noexcept { r += s; g += s; b += s; a += s; return *this; }
Fcolor& mul_rgba(float s) noexcept { r *= s; g *= s; b *= s; a *= s; return *this; }
Fcolor& mul_rgb(float s) noexcept { r *= s; g *= s; b *= s; return *this; }
Fcolor& mul_rgba(const Fcolor& c, float s) noexcept { r = c.r*s; g = c.g*s; b = c.b*s; a = c.a*s; return *this; }
Fcolor& mul_rgb(const Fcolor& c, float s) noexcept { r = c.r*s; g = c.g*s; b = c.b*s; return *this; }

// SQ magnitude
float magnitude_sqr_rgb() const throw() { return r * r + g * g + b * b;}
float magnitude_sqr_rgb() const noexcept { return r * r + g * g + b * b;}
// magnitude
float magnitude_rgb() const throw() { return _sqrt(magnitude_sqr_rgb()); }
float intensity() const throw()
float magnitude_rgb() const noexcept { return _sqrt(magnitude_sqr_rgb()); }
float intensity() const noexcept
{
// XXX: Use the component percentages from adjust_saturation()?
return (r + g + b) / 3.f;
}
// Normalize
Fcolor& normalize_rgb() throw() { VERIFY( magnitude_sqr_rgb() > EPS_S); return mul_rgb( 1.f / magnitude_rgb()); }
Fcolor& normalize_rgb(const Fcolor& c) throw() { VERIFY(c.magnitude_sqr_rgb() > EPS_S); return mul_rgb(c, 1.f / c.magnitude_rgb()); }
Fcolor& lerp(const Fcolor& c1, const Fcolor& c2, float t) throw()
Fcolor& normalize_rgb() noexcept { VERIFY( magnitude_sqr_rgb() > EPS_S); return mul_rgb( 1.f / magnitude_rgb()); }
Fcolor& normalize_rgb(const Fcolor& c) noexcept { VERIFY(c.magnitude_sqr_rgb() > EPS_S); return mul_rgb(c, 1.f / c.magnitude_rgb()); }
Fcolor& lerp(const Fcolor& c1, const Fcolor& c2, float t) noexcept
{
float invt = 1.f - t;
r = c1.r*invt + c2.r*t;
Expand All @@ -160,15 +160,15 @@ struct Fcolor
a = c1.a*invt + c2.a*t;
return *this;
}
Fcolor& lerp(const Fcolor& c1, const Fcolor& c2, const Fcolor& c3, float t) throw()
Fcolor& lerp(const Fcolor& c1, const Fcolor& c2, const Fcolor& c3, float t) noexcept
{
if (t>.5f)
return lerp(c2, c3, t*2.f - 1.f);
else
return lerp(c1, c2, t*2.f);
}
bool similar_rgba(const Fcolor& v, float E = EPS_L) const throw() { return _abs(r - v.r) < E && _abs(g - v.g) < E && _abs(b - v.b) < E && _abs(a - v.a) < E; }
bool similar_rgb (const Fcolor& v, float E = EPS_L) const throw() { return _abs(r - v.r) < E && _abs(g - v.g) < E && _abs(b - v.b) < E; }
bool similar_rgba(const Fcolor& v, float E = EPS_L) const noexcept { return _abs(r - v.r) < E && _abs(g - v.g) < E && _abs(b - v.b) < E && _abs(a - v.a) < E; }
bool similar_rgb (const Fcolor& v, float E = EPS_L) const noexcept { return _abs(r - v.r) < E && _abs(g - v.g) < E && _abs(b - v.b) < E; }
};

IC bool _valid(const Fcolor& c) throw() { return _valid(c.r) && _valid(c.g) && _valid(c.b) && _valid(c.a); }
IC bool _valid(const Fcolor& c) noexcept { return _valid(c.r) && _valid(c.g) && _valid(c.b) && _valid(c.a); }
4 changes: 2 additions & 2 deletions src/xrCore/_fbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class _box3
};
};

bool is_valid() const throw() { return (x2 >= x1) && (y2 >= y1) && (z2 >= z1); }
const T* data() const throw() { return &vMin.x; }
bool is_valid() const noexcept { return (x2 >= x1) && (y2 >= y1) && (z2 >= z1); }
const T* data() const noexcept { return &vMin.x; }

SelfRef set(const Tvector& _min, const Tvector& _max)
{
Expand Down
Loading

0 comments on commit 87e7a0b

Please sign in to comment.