diff --git a/adapter.hpp b/adapter.hpp index b25323fc..5a69a46e 100644 --- a/adapter.hpp +++ b/adapter.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace adapter { +namespace util::adapter { namespace container { // reverse a container for range-based-for template @@ -144,6 +144,6 @@ namespace util { namespace adapter { // size_t m_sequence; //}; } -} } +} #endif diff --git a/ascii.hpp b/ascii.hpp index b49cff5b..9dca4e09 100644 --- a/ascii.hpp +++ b/ascii.hpp @@ -22,7 +22,7 @@ #include #include -namespace util { namespace ascii { +namespace util::ascii { /////////////////////////////////////////////////////////////////////////// constexpr inline bool @@ -87,6 +87,6 @@ namespace util { namespace ascii { return false; } } -} } +} #endif diff --git a/cmdopt.cpp b/cmdopt.cpp index 2502396c..65fc882f 100644 --- a/cmdopt.cpp +++ b/cmdopt.cpp @@ -155,11 +155,11 @@ present::finish (void) //----------------------------------------------------------------------------- -namespace util { namespace cmdopt { namespace option { +namespace util::cmdopt::option { template class value; template class value; template class value; -} } } +} /////////////////////////////////////////////////////////////////////////////// @@ -180,9 +180,9 @@ count::execute (void) //----------------------------------------------------------------------------- -namespace util { namespace cmdopt { namespace option { +namespace util::cmdopt::option { template class count; -} } } +} /////////////////////////////////////////////////////////////////////////////// diff --git a/cmdopt.hpp b/cmdopt.hpp index 5ede712a..c86487c7 100644 --- a/cmdopt.hpp +++ b/cmdopt.hpp @@ -25,7 +25,9 @@ #include #include -namespace util { namespace cmdopt { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::cmdopt { namespace option { class base { public: @@ -199,7 +201,7 @@ namespace util { namespace cmdopt { private: const int m_index; }; -} } +} #include "cmdopt.ipp" diff --git a/cmdopt.ipp b/cmdopt.ipp index f4c3f878..2eae7d9d 100644 --- a/cmdopt.ipp +++ b/cmdopt.ipp @@ -25,7 +25,7 @@ #include "./introspection.hpp" #include "./iterator.hpp" -namespace util { namespace cmdopt { +namespace util::cmdopt { /////////////////////////////////////////////////////////////////////////// template option::value::value (T &_data): @@ -194,4 +194,4 @@ namespace util { namespace cmdopt { m_options.emplace_back (std::move (description), std::move (handler)); return ref; } -} } +} diff --git a/colour.cpp b/colour.cpp index 80d5eba5..e8d1ca7c 100644 --- a/colour.cpp +++ b/colour.cpp @@ -330,7 +330,7 @@ util::hsv_to_rgb (colour3f hsv) /// Extract a colour object from a JSON node. #include "json/tree.hpp" -namespace json { namespace tree { +namespace json::tree { template <> util::colour4f io::deserialise (const node &root) { @@ -341,7 +341,7 @@ namespace json { namespace tree { root[3].as (), }; } -} } +} /////////////////////////////////////////////////////////////////////////////// diff --git a/coord/base.hpp b/coord/base.hpp index 4f8bd4c1..8cd83fb4 100644 --- a/coord/base.hpp +++ b/coord/base.hpp @@ -24,7 +24,7 @@ #include #include -namespace util { namespace coord { +namespace util::coord { ///////////////////////////////////////////////////////////////////////// template < size_t S, @@ -142,7 +142,7 @@ namespace util { namespace coord { return out; } }; -} } +} #endif diff --git a/coord/init.hpp b/coord/init.hpp index 2307b458..5423e75b 100644 --- a/coord/init.hpp +++ b/coord/init.hpp @@ -21,7 +21,7 @@ #include -namespace util { namespace coord { +namespace util::coord { template struct init; @@ -71,6 +71,6 @@ namespace util { namespace coord { store<4,T,tags...> ({ v0, v1, v2, v3 }) { ; } }; -} } +} #endif diff --git a/coord/names.hpp b/coord/names.hpp index c8f1fda2..d34dec13 100644 --- a/coord/names.hpp +++ b/coord/names.hpp @@ -17,7 +17,7 @@ #ifndef __UTIL_COORD_NAMES_HPP #define __UTIL_COORD_NAMES_HPP -namespace util { namespace coord { +namespace util::coord { /////////////////////////////////////////////////////////////////////// // tags for accessor names // @@ -37,6 +37,6 @@ namespace util { namespace coord { // quaternions struct wxyz { }; struct abcd { }; -} } +} #endif diff --git a/coord/store.hpp b/coord/store.hpp index 87bcb517..2c67f9e5 100644 --- a/coord/store.hpp +++ b/coord/store.hpp @@ -23,7 +23,8 @@ #include -namespace util { namespace coord { + +namespace util::coord { /////////////////////////////////////////////////////////////////////////// // Coordinate storage class. // @@ -179,6 +180,6 @@ namespace util { namespace coord { struct { T a,b,c,d; }; }; }; -} } +} #endif diff --git a/crypto/arc4.hpp b/crypto/arc4.hpp index 973c822e..733782c8 100644 --- a/crypto/arc4.hpp +++ b/crypto/arc4.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace crypto { +namespace util::crypto { class ARC4 { public: ARC4 (const uint8_t *restrict key, size_t len); @@ -35,6 +35,6 @@ namespace util { namespace crypto { size_t x, y; std::array S; }; -} } +} #endif diff --git a/crypto/tea.hpp b/crypto/tea.hpp index 412dd744..c325f6c9 100644 --- a/crypto/tea.hpp +++ b/crypto/tea.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace crypto { +namespace util::crypto { // http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm class TEA { public: @@ -35,6 +35,6 @@ namespace util { namespace crypto { private: key_t m_key; }; -} } +} #endif diff --git a/crypto/xtea.hpp b/crypto/xtea.hpp index d636bed7..2b5cf788 100644 --- a/crypto/xtea.hpp +++ b/crypto/xtea.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace crypto { +namespace util::crypto { // http://en.wikipedia.org/wiki/XTEA class XTEA { public: @@ -35,6 +35,6 @@ namespace util { namespace crypto { private: key_t m_key; }; -} } +} #endif diff --git a/crypto/xxtea.hpp b/crypto/xxtea.hpp index 55ac8425..329b9a60 100644 --- a/crypto/xxtea.hpp +++ b/crypto/xxtea.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace crypto { +namespace util::crypto { // http://en.wikipedia.org/wiki/XXTEA // 'corrected' block TEA class XXTEA { @@ -36,7 +36,7 @@ namespace util { namespace crypto { private: key_t m_key; }; -} } +} #endif diff --git a/debug.hpp b/debug.hpp index 698500ad..db3e54d0 100644 --- a/debug.hpp +++ b/debug.hpp @@ -337,7 +337,7 @@ void disable_fpe (void); /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace debug { +namespace util::debug { void init (void); @@ -388,7 +388,7 @@ namespace util { namespace debug { (void)t; CHECK (is_valid (t)); } -} } +} #include "./debug.ipp" diff --git a/debug.ipp b/debug.ipp index 64287c09..5371c2e0 100644 --- a/debug.ipp +++ b/debug.ipp @@ -25,7 +25,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace debug { namespace detail { +namespace util::debug::detail { void panic [[noreturn]] (const char *msg); template @@ -38,7 +38,7 @@ namespace util { namespace debug { namespace detail { void not_implemented [[noreturn]] (const char *msg); void unreachable [[noreturn]] (const char *msg); -} } } +} // not_implemented/unreachable/panic must be callable from constexpr contexts. // but they rely on functions that aren't constexpr to perform the controlled diff --git a/format.cpp b/format.cpp index 7c9808e0..32291cf3 100644 --- a/format.cpp +++ b/format.cpp @@ -19,7 +19,7 @@ #include -namespace util { namespace format { namespace detail { +namespace util::format::detail { //------------------------------------------------------------------------- std::ostream& operator<< (std::ostream &os, specifier::repr r) @@ -72,4 +72,4 @@ namespace util { namespace format { namespace detail { "length: " << s.length << " }"; } -} } } +} diff --git a/format.hpp b/format.hpp index 7828d009..d7b69d27 100644 --- a/format.hpp +++ b/format.hpp @@ -20,7 +20,7 @@ #include #include -namespace util { namespace format { +namespace util::format { //------------------------------------------------------------------------- // render a format string using the provided values. // @@ -69,7 +69,7 @@ namespace util { namespace format { error ("missing argument for specifier") { ; } }; -} } +} #include "format.ipp" diff --git a/format.ipp b/format.ipp index 92721b40..a8258323 100644 --- a/format.ipp +++ b/format.ipp @@ -23,7 +23,7 @@ #include -namespace util { namespace format { namespace detail { +namespace util::format::detail { /////////////////////////////////////////////////////////////////////////// // GCC: workaround which allows a throw to appear in constexpr codepaths // that do not execute at compile time. See gcc#67371 @@ -933,11 +933,11 @@ namespace util { namespace format { namespace detail { return _render (os, first, last); } -} } } +} /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace format { +namespace util::format { template std::string render (const char (&fmt)[N], const Args& ...args) @@ -946,4 +946,4 @@ namespace util { namespace format { detail::render (std::back_inserter (res), fmt, args...); return res; } -} } +} diff --git a/geom/aabb.cpp b/geom/aabb.cpp index 6d8b9f29..b2601671 100644 --- a/geom/aabb.cpp +++ b/geom/aabb.cpp @@ -208,7 +208,7 @@ AABB::operator== (const AABB rhs) const //----------------------------------------------------------------------------- -namespace util { namespace debug { +namespace util::debug { template struct validator> { static bool is_valid (const AABB &b) @@ -220,7 +220,7 @@ namespace util { namespace debug { return true; } }; -} } +} //----------------------------------------------------------------------------- @@ -234,8 +234,8 @@ util::geom::operator<< (std::ostream &os, util::geom::AABB b) //----------------------------------------------------------------------------- -#define INSTANTIATE_S_T(S,T) \ -namespace util { namespace geom { template struct AABB; } } \ +#define INSTANTIATE_S_T(S,T) \ +namespace util::geom { template struct AABB; } \ template bool util::debug::is_valid (const AABB&); \ template std::ostream& util::geom::operator<< (std::ostream&, AABB); diff --git a/geom/aabb.hpp b/geom/aabb.hpp index 6dd18392..2c169d25 100644 --- a/geom/aabb.hpp +++ b/geom/aabb.hpp @@ -23,7 +23,7 @@ #include -namespace util { namespace geom { +namespace util::geom { template struct AABB { AABB () = default; @@ -64,7 +64,7 @@ namespace util { namespace geom { typedef AABB<3,float> AABB3f; typedef AABB<3,unsigned> AABB3u; typedef AABB<3,int> AABB3i; -} } +} #include "aabb.ipp" diff --git a/geom/aabb.ipp b/geom/aabb.ipp index 793f2998..78017b34 100644 --- a/geom/aabb.ipp +++ b/geom/aabb.ipp @@ -26,7 +26,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace geom { +namespace util::geom { template struct sampler { static point @@ -40,4 +40,4 @@ namespace util { namespace geom { return p * (b.p1 - b.p0) + b.p0.template as (); } }; -} } +} diff --git a/geom/cylinder.hpp b/geom/cylinder.hpp index 778d5394..b5d6884d 100644 --- a/geom/cylinder.hpp +++ b/geom/cylinder.hpp @@ -19,8 +19,8 @@ #include "../point.hpp" -namespace util { namespace geom { - /////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template struct cylinder { util::point p0, p1; @@ -30,6 +30,6 @@ namespace util { namespace geom { bool includes (util::point) const; }; -} } +} #endif diff --git a/geom/ellipse.hpp b/geom/ellipse.hpp index 00c8b97f..0dc6aa69 100644 --- a/geom/ellipse.hpp +++ b/geom/ellipse.hpp @@ -22,14 +22,14 @@ #include "../point.hpp" #include "../vector.hpp" -namespace util { namespace geom { +namespace util::geom { /////////////////////////////////////////////////////////////////////////// template struct ellipse { util::point origin; util::vector radius; }; -} } +} #include "ellipse.ipp" diff --git a/geom/ellipse.ipp b/geom/ellipse.ipp index fe7cde24..69305603 100644 --- a/geom/ellipse.ipp +++ b/geom/ellipse.ipp @@ -26,7 +26,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace geom { +namespace util::geom { template class K, typename G> struct sampler<2,T,K,G> { @@ -43,4 +43,4 @@ namespace util { namespace geom { } * rho * k.radius + k.origin.template as (); } }; -} } +} diff --git a/geom/fwd.hpp b/geom/fwd.hpp index ce44f36b..78772ffb 100644 --- a/geom/fwd.hpp +++ b/geom/fwd.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace geom { +namespace util::geom { template struct ray; template struct plane; template struct AABB; @@ -28,6 +28,6 @@ namespace util { namespace geom { template struct rect; template struct cylinder; template struct tri; -} } +} #endif diff --git a/geom/iostream.hpp b/geom/iostream.hpp index c088af94..507aecab 100644 --- a/geom/iostream.hpp +++ b/geom/iostream.hpp @@ -21,7 +21,9 @@ #include -namespace util { namespace geom { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template std::ostream& operator<< (std::ostream&, AABB); @@ -33,6 +35,6 @@ namespace util { namespace geom { template std::ostream& operator<< (std::ostream&, sphere); -} } +} #endif diff --git a/geom/ops.hpp b/geom/ops.hpp index 45868e2f..504d584d 100644 --- a/geom/ops.hpp +++ b/geom/ops.hpp @@ -20,7 +20,9 @@ #include "aabb.hpp" #include "../point.hpp" -namespace util { namespace geom { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template < size_t S, typename T, @@ -87,6 +89,6 @@ namespace util { namespace geom { > K scale (K, T); -} } +} #endif diff --git a/geom/plane.hpp b/geom/plane.hpp index 24690b74..e2cfe646 100644 --- a/geom/plane.hpp +++ b/geom/plane.hpp @@ -20,7 +20,7 @@ #include "../point.hpp" #include "../vector.hpp" -namespace util { namespace geom { +namespace util::geom { template struct plane { plane (util::point p, @@ -33,6 +33,6 @@ namespace util { namespace geom { typedef plane<2,float> plane2f; typedef plane<3,float> plane3f; -} } +} #endif diff --git a/geom/ray.hpp b/geom/ray.hpp index 58e86403..2f63abed 100644 --- a/geom/ray.hpp +++ b/geom/ray.hpp @@ -23,7 +23,9 @@ #include "../vector.hpp" #include "../point.hpp" -namespace util { namespace geom { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template struct ray { ray (point origin, @@ -50,6 +52,6 @@ namespace util { namespace geom { typedef ray<2,float> ray2f; typedef ray<3,float> ray3f; -} } +} #endif diff --git a/geom/sample.hpp b/geom/sample.hpp index 4a611d9d..bf11741f 100644 --- a/geom/sample.hpp +++ b/geom/sample.hpp @@ -19,7 +19,9 @@ #include "../point.hpp" -namespace util { namespace geom { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template < size_t S, typename T, @@ -41,7 +43,7 @@ namespace util { namespace geom { { return sampler::fn (k, g); } -} } +} #include "sample.ipp" diff --git a/geom/sample.ipp b/geom/sample.ipp index a951adbb..d74f53c9 100644 --- a/geom/sample.ipp +++ b/geom/sample.ipp @@ -22,7 +22,7 @@ #include "ops.hpp" -namespace util { namespace geom { +namespace util::geom { // use rejection sampling by default template < size_t S, @@ -41,5 +41,5 @@ namespace util { namespace geom { return p; } } -} } +} diff --git a/geom/sphere.hpp b/geom/sphere.hpp index 05845309..8f0c683a 100644 --- a/geom/sphere.hpp +++ b/geom/sphere.hpp @@ -19,7 +19,9 @@ #include "../point.hpp" -namespace util { namespace geom { + +/////////////////////////////////////////////////////////////////////////////// +namespace util::geom { template struct sphere { point centre; @@ -28,6 +30,6 @@ namespace util { namespace geom { typedef sphere<2,float> sphere2f; typedef sphere<3,float> sphere3f; -} } +} #endif diff --git a/hash.hpp b/hash.hpp index 0d915c09..878afc4e 100644 --- a/hash.hpp +++ b/hash.hpp @@ -22,9 +22,9 @@ #include #include -namespace util { namespace hash { +namespace util::hash { uint32_t mix (uint32_t v) { return wang (v); } uint64_t mix (uint64_t v) { return wang (v); } -} } +} #endif diff --git a/hash/adler.hpp b/hash/adler.hpp index 35c9f645..f233ecd7 100644 --- a/hash/adler.hpp +++ b/hash/adler.hpp @@ -23,11 +23,11 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class adler32 : public fletcher { public: adler32 (); }; -} } +} #endif diff --git a/hash/bsdsum.hpp b/hash/bsdsum.hpp index ba1bac03..871943a0 100644 --- a/hash/bsdsum.hpp +++ b/hash/bsdsum.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class bsdsum { public: using digest_t = uint16_t; @@ -40,6 +40,6 @@ namespace util { namespace hash { private: digest_t m_accum; }; -} } +} #endif diff --git a/hash/crc.hpp b/hash/crc.hpp index 222f0119..06106a80 100644 --- a/hash/crc.hpp +++ b/hash/crc.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class crc32 { public: using digest_t = uint32_t; @@ -36,7 +36,7 @@ namespace util { namespace hash { digest_t digest (void) const; }; +} -} } #endif diff --git a/hash/fasthash.hpp b/hash/fasthash.hpp index 8545e92d..a1bca98c 100644 --- a/hash/fasthash.hpp +++ b/hash/fasthash.hpp @@ -21,12 +21,12 @@ #include // Zilong Tan's FastHash, via George Marsaglia's "Xorshift RNGs" -namespace util { namespace hash { namespace fasthash { +namespace util::hash::fasthash { uint64_t mix (uint64_t); uint32_t hash32 (const void *restrict data, size_t len, uint32_t seed); uint64_t hash64 (const void *restrict data, size_t len, uint64_t seed); -} } } +} #endif diff --git a/hash/fletcher.hpp b/hash/fletcher.hpp index 7eebae5b..d232b4a7 100644 --- a/hash/fletcher.hpp +++ b/hash/fletcher.hpp @@ -24,7 +24,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { template class fletcher { public: @@ -51,7 +51,7 @@ namespace util { namespace hash { const state_t m_initial; state_t m_state; }; -} } +} #endif diff --git a/hash/fnv1a.hpp b/hash/fnv1a.hpp index ab52b75e..c75e241a 100644 --- a/hash/fnv1a.hpp +++ b/hash/fnv1a.hpp @@ -20,10 +20,10 @@ #include #include -namespace util { namespace hash { +namespace util::hash { // Fast and general hashing using FNV-1a uint32_t fnv1a32 (const void *restrict, size_t); uint64_t fnv1a64 (const void *restrict, size_t); -} } +} #endif diff --git a/hash/fwd.hpp b/hash/fwd.hpp index 2ba8330b..e8703dc2 100644 --- a/hash/fwd.hpp +++ b/hash/fwd.hpp @@ -27,7 +27,7 @@ // Forward declerations of class based hashes -namespace util { namespace hash { +namespace util::hash { template class HMAC; // checksums @@ -49,6 +49,6 @@ namespace util { namespace hash { class RIPEMD; class SHA1; class SHA256; -} } +} #endif diff --git a/hash/hmac.hpp b/hash/hmac.hpp index 696aa101..23e49b8e 100644 --- a/hash/hmac.hpp +++ b/hash/hmac.hpp @@ -21,7 +21,7 @@ #include #include -namespace util { namespace hash { +namespace util::hash { template /// RFC 2104 key-hashing for message authentication class HMAC { @@ -42,6 +42,6 @@ namespace util { namespace hash { T m_hash; }; -} } +} #endif diff --git a/hash/hotp.hpp b/hash/hotp.hpp index 10844b8e..2d9bf406 100644 --- a/hash/hotp.hpp +++ b/hash/hotp.hpp @@ -22,7 +22,7 @@ #include -namespace util { namespace hash { +namespace util::hash { /// HMAC one-time password (RFC 4226) class HOTP { public: @@ -38,6 +38,6 @@ namespace util { namespace hash { uint64_t m_counter; HMAC m_hash; }; -} } +} #endif diff --git a/hash/md2.hpp b/hash/md2.hpp index 3c2f6374..2bc2b331 100644 --- a/hash/md2.hpp +++ b/hash/md2.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class MD2 { public: typedef std::array digest_t; @@ -45,6 +45,6 @@ namespace util { namespace hash { uint8_t C[16]; uint8_t X[48]; }; -} } +} #endif diff --git a/hash/md4.hpp b/hash/md4.hpp index dad98dee..91e94486 100644 --- a/hash/md4.hpp +++ b/hash/md4.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class MD4 { public: typedef std::array digest_t; @@ -48,6 +48,6 @@ namespace util { namespace hash { uint8_t Xb[64]; }; }; -} } +} #endif diff --git a/hash/md5.hpp b/hash/md5.hpp index 1cfb1de0..2bb2a9a5 100644 --- a/hash/md5.hpp +++ b/hash/md5.hpp @@ -23,7 +23,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class MD5 { public: typedef std::array digest_t; @@ -51,6 +51,6 @@ namespace util { namespace hash { uint8_t Xb[64]; }; }; -} } +} #endif diff --git a/hash/murmur/common.cpp b/hash/murmur/common.cpp index f455b15b..101672bb 100644 --- a/hash/murmur/common.cpp +++ b/hash/murmur/common.cpp @@ -18,117 +18,124 @@ #include "../../debug.hpp" + /////////////////////////////////////////////////////////////////////////////// -uint32_t -util::hash::murmur::tail (const uint32_t *restrict data, size_t len) -{ - auto bytes = reinterpret_cast (data); - uint32_t h = 0; - - switch (len % sizeof (uint32_t)) { - case 3: h += bytes[2] << 16; - case 2: h += bytes[1] << 8; - case 1: h += bytes[0]; - break; - - default: - unreachable (); - } - - return h; -} - - -//----------------------------------------------------------------------------- -uint64_t -util::hash::murmur::tail (const uint64_t *restrict data, size_t len) -{ - auto bytes = reinterpret_cast (data); - uint64_t h = 0; - - switch (len % sizeof (uint64_t)) { - case 7: h += uint64_t(bytes[6]) << 48; - case 6: h += uint64_t(bytes[5]) << 40; - case 5: h += uint64_t(bytes[4]) << 32; - case 4: h += uint64_t(bytes[3]) << 24; - case 3: h += uint64_t(bytes[2]) << 16; - case 2: h += uint64_t(bytes[1]) << 8; - case 1: h += uint64_t(bytes[0]); - break; - - default: - unreachable (); - } - - return h; -} - - -//----------------------------------------------------------------------------- -std::array -util::hash::murmur::tail_array (const uint32_t *restrict data, size_t len) -{ - auto bytes = reinterpret_cast (data); - std::array result {0,0,0,0}; - - switch (len % 16) { - case 15: result[3] |= bytes[14] << 16; - case 14: result[3] |= bytes[13] << 8; - case 13: result[3] |= bytes[12] << 0; - case 12: result[2] |= bytes[11] << 24; - case 11: result[2] |= bytes[10] << 16; - case 10: result[2] |= bytes[ 9] << 8; - case 9: result[2] |= bytes[ 8] << 0; - case 8: result[1] |= bytes[ 7] << 24; - case 7: result[1] |= bytes[ 6] << 16; - case 6: result[1] |= bytes[ 5] << 8; - case 5: result[1] |= bytes[ 4] << 0; - case 4: result[0] |= bytes[ 3] << 24; - case 3: result[0] |= bytes[ 2] << 16; - case 2: result[0] |= bytes[ 1] << 8; - case 1: result[0] |= bytes[ 0] << 0; - break; - - default: - unreachable (); - } - - return result; -} - - -//----------------------------------------------------------------------------- -std::array -util::hash::murmur::tail_array (const uint64_t *restrict data, size_t len) -{ - auto bytes = reinterpret_cast (data); - std::array result {0, 0}; - - switch(len & 15) +namespace util::hash::murmur { + template <> + uint32_t + tail (const uint8_t *restrict bytes, size_t len) { - case 15: result[1] |= ((uint64_t)bytes[14]) << 48; - case 14: result[1] |= ((uint64_t)bytes[13]) << 40; - case 13: result[1] |= ((uint64_t)bytes[12]) << 32; - case 12: result[1] |= ((uint64_t)bytes[11]) << 24; - case 11: result[1] |= ((uint64_t)bytes[10]) << 16; - case 10: result[1] |= ((uint64_t)bytes[ 9]) << 8; - case 9: result[1] |= ((uint64_t)bytes[ 8]) << 0; + uint32_t h = 0; - case 8: result[0] |= ((uint64_t)bytes[ 7]) << 56; - case 7: result[0] |= ((uint64_t)bytes[ 6]) << 48; - case 6: result[0] |= ((uint64_t)bytes[ 5]) << 40; - case 5: result[0] |= ((uint64_t)bytes[ 4]) << 32; - case 4: result[0] |= ((uint64_t)bytes[ 3]) << 24; - case 3: result[0] |= ((uint64_t)bytes[ 2]) << 16; - case 2: result[0] |= ((uint64_t)bytes[ 1]) << 8; - case 1: result[0] |= ((uint64_t)bytes[ 0]) << 0; - break; + switch (len % sizeof (uint32_t)) { + case 3: h += bytes[2] << 16; + case 2: h += bytes[1] << 8; + case 1: h += bytes[0]; + break; - default: - unreachable (); - }; + default: + unreachable (); + } - return result; + return h; + } } +//----------------------------------------------------------------------------- +namespace util::hash::murmur { + template <> + uint64_t + tail (const uint8_t *restrict bytes, size_t len) + { + uint64_t h = 0; + + switch (len % sizeof (uint64_t)) { + case 7: h += uint64_t(bytes[6]) << 48; + case 6: h += uint64_t(bytes[5]) << 40; + case 5: h += uint64_t(bytes[4]) << 32; + case 4: h += uint64_t(bytes[3]) << 24; + case 3: h += uint64_t(bytes[2]) << 16; + case 2: h += uint64_t(bytes[1]) << 8; + case 1: h += uint64_t(bytes[0]); + break; + + default: + unreachable (); + } + + return h; + } +} + + +//----------------------------------------------------------------------------- +namespace util::hash::murmur { + template <> + std::array + tail_array (const uint8_t *restrict bytes, size_t len) + { + std::array result {0,0,0,0}; + + switch (len % 16) { + case 15: result[3] |= bytes[14] << 16; + case 14: result[3] |= bytes[13] << 8; + case 13: result[3] |= bytes[12] << 0; + case 12: result[2] |= bytes[11] << 24; + case 11: result[2] |= bytes[10] << 16; + case 10: result[2] |= bytes[ 9] << 8; + case 9: result[2] |= bytes[ 8] << 0; + case 8: result[1] |= bytes[ 7] << 24; + case 7: result[1] |= bytes[ 6] << 16; + case 6: result[1] |= bytes[ 5] << 8; + case 5: result[1] |= bytes[ 4] << 0; + case 4: result[0] |= bytes[ 3] << 24; + case 3: result[0] |= bytes[ 2] << 16; + case 2: result[0] |= bytes[ 1] << 8; + case 1: result[0] |= bytes[ 0] << 0; + break; + + default: + unreachable (); + } + + return result; + } +} + + +//----------------------------------------------------------------------------- +namespace util::hash::murmur { + template <> + std::array + tail_array (const uint8_t *restrict bytes, size_t len) + { + std::array result {0, 0}; + + switch(len & 15) + { + case 15: result[1] |= ((uint64_t)bytes[14]) << 48; + case 14: result[1] |= ((uint64_t)bytes[13]) << 40; + case 13: result[1] |= ((uint64_t)bytes[12]) << 32; + case 12: result[1] |= ((uint64_t)bytes[11]) << 24; + case 11: result[1] |= ((uint64_t)bytes[10]) << 16; + case 10: result[1] |= ((uint64_t)bytes[ 9]) << 8; + case 9: result[1] |= ((uint64_t)bytes[ 8]) << 0; + + case 8: result[0] |= ((uint64_t)bytes[ 7]) << 56; + case 7: result[0] |= ((uint64_t)bytes[ 6]) << 48; + case 6: result[0] |= ((uint64_t)bytes[ 5]) << 40; + case 5: result[0] |= ((uint64_t)bytes[ 4]) << 32; + case 4: result[0] |= ((uint64_t)bytes[ 3]) << 24; + case 3: result[0] |= ((uint64_t)bytes[ 2]) << 16; + case 2: result[0] |= ((uint64_t)bytes[ 1]) << 8; + case 1: result[0] |= ((uint64_t)bytes[ 0]) << 0; + break; + + default: + unreachable (); + }; + + return result; + } +} diff --git a/hash/murmur/common.hpp b/hash/murmur/common.hpp index 5049e958..fc2e5bd6 100644 --- a/hash/murmur/common.hpp +++ b/hash/murmur/common.hpp @@ -19,13 +19,12 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { namespace murmur { - uint32_t tail (const uint32_t *restrict data, size_t len); - uint64_t tail (const uint64_t *restrict data, size_t len); +namespace util::hash::murmur { + template + T + tail (const uint8_t *restrict data, size_t len); - std::array - tail_array (const uint32_t *restrict data, size_t len); - - std::array - tail_array (const uint64_t *restrict data, size_t len); -} } } + template + std::array + tail_array (const uint8_t *restrict data, size_t len); +} diff --git a/hash/murmur/murmur1.cpp b/hash/murmur/murmur1.cpp index 38cf2004..e4a84bee 100644 --- a/hash/murmur/murmur1.cpp +++ b/hash/murmur/murmur1.cpp @@ -42,7 +42,7 @@ util::hash::murmur1::hash_32 (const void *restrict data, CHECK (data); static const uint32_t m = 0xc6a4a793; - uint32_t h = seed ^ (uint32_t (len) * m); + uint32_t h = seed ^ ((len & 0xffffffff) * m); // mix the body auto cursor = reinterpret_cast (data); @@ -52,7 +52,7 @@ util::hash::murmur1::hash_32 (const void *restrict data, // mix the tail if (len % sizeof (uint32_t)) - h = mix (h, murmur::tail (cursor, len)); + h = mix (h, murmur::tail (reinterpret_cast (cursor), len)); // finalise h *= m; h ^= h >> 10; diff --git a/hash/murmur/murmur1.hpp b/hash/murmur/murmur1.hpp index c28b7635..cda30847 100644 --- a/hash/murmur/murmur1.hpp +++ b/hash/murmur/murmur1.hpp @@ -21,9 +21,9 @@ #include // Austin Appleby's MumurHash1 -namespace util { namespace hash { namespace murmur1 { +namespace util::hash::murmur1 { uint32_t mix (uint32_t, uint32_t); uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); -} } } +} #endif diff --git a/hash/murmur/murmur2.cpp b/hash/murmur/murmur2.cpp index 79773fa3..f444c8f8 100644 --- a/hash/murmur/murmur2.cpp +++ b/hash/murmur/murmur2.cpp @@ -31,7 +31,7 @@ util::hash::murmur2::hash_32 (const void *restrict key, // setup constexpr auto m = detail::constants::m; - uint32_t h = seed ^ uint32_t (len); + uint32_t h = seed ^ (len & 0xffffffff); // body auto cursor = reinterpret_cast (key); @@ -41,7 +41,7 @@ util::hash::murmur2::hash_32 (const void *restrict key, // tail if (len % sizeof (uint32_t)) { - h ^= murmur::tail (cursor, len); + h ^= murmur::tail (reinterpret_cast (cursor), len); h *= m; } @@ -74,7 +74,7 @@ util::hash::murmur2::hash_64 (const void *restrict key, // tail if (len % sizeof (uint64_t)) { - h ^= murmur::tail (cursor, len); + h ^= murmur::tail (reinterpret_cast (cursor), len); h *= m; } diff --git a/hash/murmur/murmur2.hpp b/hash/murmur/murmur2.hpp index 84fa4c3c..721e148c 100644 --- a/hash/murmur/murmur2.hpp +++ b/hash/murmur/murmur2.hpp @@ -23,13 +23,13 @@ // Austin Appleby's MumurHash2, and MurmurHash64A. The exhaustive list of // variants is deliberately not provided. You can damn well align your data or // fix the algorithm. -namespace util { namespace hash { namespace murmur2 { +namespace util::hash::murmur2 { constexpr uint32_t mix (uint32_t, uint32_t); constexpr uint64_t mix (uint64_t, uint64_t); uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); uint64_t hash_64 (const void *restrict data, size_t len, uint64_t seed); -} } } +} #include "./murmur2.ipp" diff --git a/hash/murmur/murmur2.ipp b/hash/murmur/murmur2.ipp index 5af8a497..430ce60b 100644 --- a/hash/murmur/murmur2.ipp +++ b/hash/murmur/murmur2.ipp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { namespace murmur2 { namespace detail { +namespace util::hash::murmur2::detail { template struct constants; template <> @@ -36,7 +36,7 @@ namespace util { namespace hash { namespace murmur2 { namespace detail { static const uint64_t m = 0xc6a4a7935bd1e995; static const int64_t r = 47; }; -} } } } +} ///////////////////////////////////////////////////////////////////// diff --git a/hash/murmur/murmur3.cpp b/hash/murmur/murmur3.cpp index 9e7b47e5..1fc54b64 100644 --- a/hash/murmur/murmur3.cpp +++ b/hash/murmur/murmur3.cpp @@ -22,6 +22,18 @@ #include +/////////////////////////////////////////////////////////////////////////////// +static +uint32_t +read_u32 (const uint8_t *bytes) +{ + return bytes[0] << 0 | + bytes[1] << 8 | + bytes[2] << 16 | + bytes[3] << 24; +} + + /////////////////////////////////////////////////////////////////////////////// // Finalization mix - force all bits of a hash block to avalanche uint32_t @@ -67,10 +79,10 @@ util::hash::murmur3::hash_32(const void *restrict key, //---------- // body - auto cursor = reinterpret_cast (data); - auto last = cursor + nblocks; - for (; cursor < last; ++cursor) { - uint32_t k1 = *cursor; + auto cursor = data; + auto last = cursor + nblocks * sizeof (uint32_t); + for (; cursor < last; cursor += sizeof (uint32_t)) { + uint32_t k1 = read_u32 (cursor); k1 *= c1; k1 = util::rotatel (k1, 15); @@ -85,7 +97,7 @@ util::hash::murmur3::hash_32(const void *restrict key, //---------- // tail if (len % sizeof (uint32_t)) { - uint32_t k1 = 0 ^ murmur::tail (cursor, len); + uint32_t k1 = 0 ^ murmur::tail (cursor, len); k1 *= c1; k1 = util::rotatel (k1, 15); @@ -208,7 +220,7 @@ hash_128 (const void *restrict key, // process the tail if (len % 16) { - auto k = util::hash::murmur::tail_array (cursor, len); + auto k = util::hash::murmur::tail_array (reinterpret_cast (cursor), len); for (auto &v: k) v = 0 ^ v; diff --git a/hash/murmur/murmur3.hpp b/hash/murmur/murmur3.hpp index 3beec12a..71ac45a7 100644 --- a/hash/murmur/murmur3.hpp +++ b/hash/murmur/murmur3.hpp @@ -22,14 +22,14 @@ #include // Austin Appleby's MurmurHash3 -namespace util { namespace hash { namespace murmur3 { +namespace util::hash::murmur3 { uint32_t mix (uint32_t); uint64_t mix (uint64_t); uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); std::array hash_128_x86 (const void *restrict data, size_t len, uint32_t seed); std::array hash_128_x64 (const void *restrict data, size_t len, uint32_t seed); -} } } +} #endif diff --git a/hash/ripemd.hpp b/hash/ripemd.hpp index 1ab6db67..2612d880 100644 --- a/hash/ripemd.hpp +++ b/hash/ripemd.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class RIPEMD { public: typedef std::array digest_t; @@ -53,6 +53,6 @@ namespace util { namespace hash { size_t size; } m_buffer; }; -} } +} #endif diff --git a/hash/sha1.hpp b/hash/sha1.hpp index 022018e3..b34d8efe 100644 --- a/hash/sha1.hpp +++ b/hash/sha1.hpp @@ -24,7 +24,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class SHA1 { public: typedef std::array digest_t; @@ -59,6 +59,6 @@ namespace util { namespace hash { uint32_t W[16 +64 ]; }; }; -} } +} #endif diff --git a/hash/sha2.hpp b/hash/sha2.hpp index c72f65b6..cb296971 100644 --- a/hash/sha2.hpp +++ b/hash/sha2.hpp @@ -23,7 +23,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { class SHA256 { public: typedef std::array digest_t; @@ -50,6 +50,6 @@ namespace util { namespace hash { std::array C; }; }; -} } +} #endif diff --git a/hash/simple.hpp b/hash/simple.hpp index 485126fd..75d020b1 100644 --- a/hash/simple.hpp +++ b/hash/simple.hpp @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace hash { +namespace util::hash { //template template typename H::digest_t @@ -38,6 +38,6 @@ namespace util { namespace hash { return h.digest (); } -} } +} #endif diff --git a/hash/wang.hpp b/hash/wang.hpp index c393639e..7b1d23b7 100644 --- a/hash/wang.hpp +++ b/hash/wang.hpp @@ -19,11 +19,11 @@ #include -namespace util { namespace hash { +namespace util::hash { // Thomas Wang's integer mixing functions, ca 2007 constexpr uint32_t wang (uint32_t); constexpr uint64_t wang (uint64_t); -} } +} #include "wang.ipp" diff --git a/io_posix.hpp b/io_posix.hpp index 2d00b4f1..0eae93eb 100644 --- a/io_posix.hpp +++ b/io_posix.hpp @@ -28,7 +28,7 @@ #include namespace util { - namespace detail { namespace posix { + namespace detail::posix { class mapped_file { public: mapped_file (const std::experimental::filesystem::path&, int fflags = O_RDONLY | O_BINARY, int mflags = PROT_READ); @@ -73,7 +73,7 @@ namespace util { uint8_t *m_data; size_t m_size; }; - } } + } typedef detail::posix::mapped_file mapped_file; } diff --git a/io_win32.hpp b/io_win32.hpp index 06197087..079da417 100644 --- a/io_win32.hpp +++ b/io_win32.hpp @@ -51,7 +51,7 @@ enum : int { /////////////////////////////////////////////////////////////////////////////// // implementation definitions namespace util { - namespace detail { namespace win32 { + namespace detail::win32 { class mapped_file { public: mapped_file (::util::win32::handle &&, @@ -97,7 +97,7 @@ namespace util { std::unique_ptr m_data; uint64_t m_size; }; - } } + } typedef detail::win32::mapped_file mapped_file; } diff --git a/json/flat.hpp b/json/flat.hpp index 0c567bd2..b645dc63 100644 --- a/json/flat.hpp +++ b/json/flat.hpp @@ -22,7 +22,9 @@ #include "../view.hpp" -namespace json { namespace flat { + +/////////////////////////////////////////////////////////////////////////////// +namespace json::flat { enum class type { UNKNOWN, @@ -53,6 +55,6 @@ namespace json { namespace flat { std::vector> parse (util::view data); std::ostream& operator<< (std::ostream&, type); -} } +} #endif diff --git a/json/schema.hpp b/json/schema.hpp index 4e828103..6522d85c 100644 --- a/json/schema.hpp +++ b/json/schema.hpp @@ -21,7 +21,9 @@ #include -namespace json { namespace schema { + +/////////////////////////////////////////////////////////////////////////////// +namespace json::schema { // Validate the json tree using the provide schema object or path. // // Note that the data object being validated may be altered in the process @@ -29,6 +31,6 @@ namespace json { namespace schema { // default, it will be realised in the data object. void validate (json::tree::node &data, const json::tree::object &schema); void validate (json::tree::node &data, const std::experimental::filesystem::path &schema); -} } +} #endif diff --git a/json/tree.cpp b/json/tree.cpp index f650b28b..c67e29f1 100644 --- a/json/tree.cpp +++ b/json/tree.cpp @@ -377,7 +377,7 @@ json::tree::node::as_chars (void) const& /////////////////////////////////////////////////////////////////////////////// -namespace json { namespace tree { +namespace json::tree { #if defined(__clang__) #elif defined(__GNUC__) #pragma GCC diagnostic push @@ -445,7 +445,7 @@ namespace json { namespace tree { #elif defined(__GNUC__) #pragma GCC diagnostic pop #endif -} } +} /////////////////////////////////////////////////////////////////////////////// @@ -1009,7 +1009,7 @@ json::tree::operator<< (std::ostream &os, const json::tree::node &n) //----------------------------------------------------------------------------- // to_json -namespace json { namespace tree { +namespace json::tree { template <> std::unique_ptr io::serialise (const bool &b) { @@ -1057,4 +1057,4 @@ namespace json { namespace tree { io::serialise (const float &f) { return std::unique_ptr (new number (f)); } -} } +} diff --git a/json/tree.hpp b/json/tree.hpp index c36d0a2f..8cf3708f 100644 --- a/json/tree.hpp +++ b/json/tree.hpp @@ -32,7 +32,8 @@ #include -namespace json { namespace tree { +/////////////////////////////////////////////////////////////////////////////// +namespace json::tree { enum type_t { OBJECT, ARRAY, @@ -354,8 +355,10 @@ namespace json { namespace tree { static std::unique_ptr serialise (const T&); static T deserialise (const json::tree::node&); }; -} } +} + +/////////////////////////////////////////////////////////////////////////////// template std::unique_ptr to_json (const T &t, Args&&... args) @@ -365,6 +368,8 @@ to_json (const T &t, Args&&... args) ); } + +/////////////////////////////////////////////////////////////////////////////// template T from_json (const json::tree::node &n, Args&&... args) @@ -375,5 +380,3 @@ from_json (const json::tree::node &n, Args&&... args) } #endif - - diff --git a/library_win32.hpp b/library_win32.hpp index 25226c68..320b2a85 100644 --- a/library_win32.hpp +++ b/library_win32.hpp @@ -22,7 +22,7 @@ #include namespace util { - namespace detail { namespace win32 { + namespace detail::win32 { class library { public: library (const std::experimental::filesystem::path&); @@ -33,7 +33,7 @@ namespace util { private: HMODULE m_handle; }; - } } + } typedef detail::win32::library library; } diff --git a/memory/buffer/circular.hpp b/memory/buffer/circular.hpp index e853bfaf..387cb9c2 100644 --- a/memory/buffer/circular.hpp +++ b/memory/buffer/circular.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace memory { namespace buffer { +namespace util::memory::buffer { // buffer size is advisory and will likely depend on page size. the user // must check the size after creation if this field is important for // their usage. @@ -50,6 +50,6 @@ namespace util { namespace memory { namespace buffer { char *m_begin, *m_end; }; -} } } +} #endif diff --git a/memory/buffer/paged.hpp b/memory/buffer/paged.hpp index 6cba9bc7..8d9fb6e9 100644 --- a/memory/buffer/paged.hpp +++ b/memory/buffer/paged.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace memory { namespace buffer { +namespace util::memory::buffer { class paged { public: using value_type = char; @@ -54,6 +54,6 @@ namespace util { namespace memory { namespace buffer { char *m_begin, *m_end, *m_cursor; size_t m_window; }; -} } } +} #endif diff --git a/memory/deleter.hpp b/memory/deleter.hpp index 1e85160e..ceaf030a 100644 --- a/memory/deleter.hpp +++ b/memory/deleter.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace memory { +namespace util::memory { template class func_deleter { public: @@ -57,6 +57,6 @@ namespace util { namespace memory { private: U& m_owner; }; -} } +} #endif diff --git a/memory/system.hpp b/memory/system.hpp index da9259d0..9bf297ef 100644 --- a/memory/system.hpp +++ b/memory/system.hpp @@ -19,8 +19,8 @@ #include -namespace util { namespace memory { +namespace util::memory { size_t pagesize (void); -} } +} #endif diff --git a/posix/dir.hpp b/posix/dir.hpp index 53890ed7..d27d6d68 100644 --- a/posix/dir.hpp +++ b/posix/dir.hpp @@ -22,7 +22,7 @@ #include #include -namespace util { namespace posix { +namespace util::posix { struct dir { public: explicit dir (const std::experimental::filesystem::path&); @@ -46,7 +46,7 @@ namespace util { namespace posix { private: DIR *m_handle; }; -} } +} #include "./dir.ipp" diff --git a/rand/lcg.hpp b/rand/lcg.hpp index 1cacc885..75a2d309 100644 --- a/rand/lcg.hpp +++ b/rand/lcg.hpp @@ -21,7 +21,7 @@ #include -namespace util { namespace rand { +namespace util::rand { /// linear congruential generator /// /// T: output/state type @@ -50,6 +50,6 @@ namespace util { namespace rand { // glibc: typedef lcg lcg_t; using lcg_t = lcg; -} } +} #endif diff --git a/rand/mwc64x.hpp b/rand/mwc64x.hpp index 12ef5441..066b5570 100644 --- a/rand/mwc64x.hpp +++ b/rand/mwc64x.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace rand { +namespace util::rand { // multiply-with-carry style generator suitable for rapid seeking and // GPU generation. // @@ -37,7 +37,7 @@ namespace util { namespace rand { private: uint64_t m_state; }; -} } +} #endif diff --git a/rand/xorshift.hpp b/rand/xorshift.hpp index ccef2e81..e5a57369 100644 --- a/rand/xorshift.hpp +++ b/rand/xorshift.hpp @@ -17,7 +17,7 @@ #ifndef __UTIL_RAND_XORSHIFT_HPP #define __UTIL_RAND_XORSHIFT_HPP -namespace util { namespace rand { +namespace util::rand { // implements a naive xorshift random generator. // // * does not comply with the c++11 rng class requirements @@ -40,6 +40,6 @@ namespace util { namespace rand { private: T m_state; }; -} } +} #endif diff --git a/region.cpp b/region.cpp index be9712c5..80a5a169 100644 --- a/region.cpp +++ b/region.cpp @@ -345,7 +345,7 @@ util::operator<< (std::ostream &os, const util::region &rhs) { /////////////////////////////////////////////////////////////////////////////// -namespace util { namespace debug { +namespace util::debug { template struct validator> { static bool is_valid (const util::region &r) @@ -353,7 +353,7 @@ namespace util { namespace debug { return util::debug::is_valid (r.p) && util::debug::is_valid (r.e); } }; -} } +} /////////////////////////////////////////////////////////////////////////////// diff --git a/roots/bisection.hpp b/roots/bisection.hpp index b6e8935f..849509a2 100644 --- a/roots/bisection.hpp +++ b/roots/bisection.hpp @@ -21,7 +21,7 @@ #include -namespace util { namespace roots { +namespace util::roots { /// find a root of a function using the bisection method /// /// the user is responsible for ensuring there is in fact a root. there @@ -64,6 +64,6 @@ namespace util { namespace roots { // valid mathematically. return (a + b) / T{2}; } -} } +} #endif diff --git a/tap.hpp b/tap.hpp index 613468bf..b6f43032 100644 --- a/tap.hpp +++ b/tap.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace TAP { +namespace util::TAP { /// A simple TAP (Test Anything Protocol) test case output class logger { public: @@ -84,7 +84,7 @@ namespace util { namespace TAP { int m_status; size_t m_size; }; -} } +} #include "tap.ipp" diff --git a/term.hpp b/term.hpp index 88ed960c..6b97bcc5 100644 --- a/term.hpp +++ b/term.hpp @@ -19,7 +19,7 @@ #include -namespace util { namespace term { +namespace util::term { bool has_csi_support (void); namespace csi { @@ -63,6 +63,6 @@ namespace util { namespace term { std::ostream& operator<< (std::ostream&, code); std::ostream& operator<< (std::ostream&, graphics); } -} } +} #endif diff --git a/tuple.hpp b/tuple.hpp index d7b4245d..6b54d4ee 100644 --- a/tuple.hpp +++ b/tuple.hpp @@ -24,7 +24,7 @@ #include -namespace util { namespace tuple { +namespace util::tuple { /////////////////////////////////////////////////////////////////////////// /// call a provided object with type_tag for each type in a tuple template < @@ -163,7 +163,7 @@ namespace util { namespace tuple { >::type... > type; }; -} } +} #endif diff --git a/win32/handle.hpp b/win32/handle.hpp index 30ddd890..865248f8 100644 --- a/win32/handle.hpp +++ b/win32/handle.hpp @@ -16,7 +16,7 @@ #include -namespace util { namespace win32 { +namespace util::win32 { struct handle { handle (); explicit handle (HANDLE&&); @@ -36,4 +36,4 @@ namespace util { namespace win32 { private: HANDLE m_native; }; -} } +} diff --git a/win32/registry.hpp b/win32/registry.hpp index 18787f9a..9357d9fe 100644 --- a/win32/registry.hpp +++ b/win32/registry.hpp @@ -22,7 +22,7 @@ #include #include -namespace util { namespace win32 { +namespace util::win32 { class key { public: key (HKEY root, const char *child, REGSAM rights = KEY_READ); @@ -37,6 +37,6 @@ namespace util { namespace win32 { private: HKEY m_handle; }; -} } +} #endif