use nested namespace declarations

This commit is contained in:
Danny Robson 2017-01-05 15:06:49 +11:00
parent c4ca41d6c4
commit 353cf839d4
82 changed files with 329 additions and 291 deletions

View File

@ -21,7 +21,7 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
namespace util { namespace adapter { namespace util::adapter {
namespace container { namespace container {
// reverse a container for range-based-for // reverse a container for range-based-for
template <typename T> template <typename T>
@ -144,6 +144,6 @@ namespace util { namespace adapter {
// size_t m_sequence; // size_t m_sequence;
//}; //};
} }
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
#include <cstdint> #include <cstdint>
#include <stdexcept> #include <stdexcept>
namespace util { namespace ascii { namespace util::ascii {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
constexpr inline constexpr inline
bool bool
@ -87,6 +87,6 @@ namespace util { namespace ascii {
return false; return false;
} }
} }
} } }
#endif #endif

View File

@ -155,11 +155,11 @@ present::finish (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util { namespace cmdopt { namespace option { namespace util::cmdopt::option {
template class value<uint16_t>; template class value<uint16_t>;
template class value<uint32_t>; template class value<uint32_t>;
template class value<uint64_t>; template class value<uint64_t>;
} } } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -180,9 +180,9 @@ count<T>::execute (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util { namespace cmdopt { namespace option { namespace util::cmdopt::option {
template class count<unsigned>; template class count<unsigned>;
} } } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -25,7 +25,9 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
namespace util { namespace cmdopt {
///////////////////////////////////////////////////////////////////////////////
namespace util::cmdopt {
namespace option { namespace option {
class base { class base {
public: public:
@ -199,7 +201,7 @@ namespace util { namespace cmdopt {
private: private:
const int m_index; const int m_index;
}; };
} } }
#include "cmdopt.ipp" #include "cmdopt.ipp"

View File

@ -25,7 +25,7 @@
#include "./introspection.hpp" #include "./introspection.hpp"
#include "./iterator.hpp" #include "./iterator.hpp"
namespace util { namespace cmdopt { namespace util::cmdopt {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
option::value<T>::value (T &_data): option::value<T>::value (T &_data):
@ -194,4 +194,4 @@ namespace util { namespace cmdopt {
m_options.emplace_back (std::move (description), std::move (handler)); m_options.emplace_back (std::move (description), std::move (handler));
return ref; return ref;
} }
} } }

View File

@ -330,7 +330,7 @@ util::hsv_to_rgb (colour3f hsv)
/// Extract a colour object from a JSON node. /// Extract a colour object from a JSON node.
#include "json/tree.hpp" #include "json/tree.hpp"
namespace json { namespace tree { namespace json::tree {
template <> template <>
util::colour4f util::colour4f
io<util::colour4f>::deserialise (const node &root) { io<util::colour4f>::deserialise (const node &root) {
@ -341,7 +341,7 @@ namespace json { namespace tree {
root[3].as<float> (), root[3].as<float> (),
}; };
} }
} } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -24,7 +24,7 @@
#include <cstdlib> #include <cstdlib>
#include <type_traits> #include <type_traits>
namespace util { namespace coord { namespace util::coord {
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
template < template <
size_t S, size_t S,
@ -142,7 +142,7 @@ namespace util { namespace coord {
return out; return out;
} }
}; };
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace coord { namespace util::coord {
template <size_t S, typename T, typename...> template <size_t S, typename T, typename...>
struct init; struct init;
@ -71,6 +71,6 @@ namespace util { namespace coord {
store<4,T,tags...> ({ v0, v1, v2, v3 }) store<4,T,tags...> ({ v0, v1, v2, v3 })
{ ; } { ; }
}; };
} } }
#endif #endif

View File

@ -17,7 +17,7 @@
#ifndef __UTIL_COORD_NAMES_HPP #ifndef __UTIL_COORD_NAMES_HPP
#define __UTIL_COORD_NAMES_HPP #define __UTIL_COORD_NAMES_HPP
namespace util { namespace coord { namespace util::coord {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// tags for accessor names // tags for accessor names
// //
@ -37,6 +37,6 @@ namespace util { namespace coord {
// quaternions // quaternions
struct wxyz { }; struct wxyz { };
struct abcd { }; struct abcd { };
} } }
#endif #endif

View File

@ -23,7 +23,8 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace coord {
namespace util::coord {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Coordinate storage class. // Coordinate storage class.
// //
@ -179,6 +180,6 @@ namespace util { namespace coord {
struct { T a,b,c,d; }; struct { T a,b,c,d; };
}; };
}; };
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace util { namespace crypto { namespace util::crypto {
class ARC4 { class ARC4 {
public: public:
ARC4 (const uint8_t *restrict key, size_t len); ARC4 (const uint8_t *restrict key, size_t len);
@ -35,6 +35,6 @@ namespace util { namespace crypto {
size_t x, y; size_t x, y;
std::array<uint8_t,256> S; std::array<uint8_t,256> S;
}; };
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace util { namespace crypto { namespace util::crypto {
// http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm // http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
class TEA { class TEA {
public: public:
@ -35,6 +35,6 @@ namespace util { namespace crypto {
private: private:
key_t m_key; key_t m_key;
}; };
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace util { namespace crypto { namespace util::crypto {
// http://en.wikipedia.org/wiki/XTEA // http://en.wikipedia.org/wiki/XTEA
class XTEA { class XTEA {
public: public:
@ -35,6 +35,6 @@ namespace util { namespace crypto {
private: private:
key_t m_key; key_t m_key;
}; };
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace util { namespace crypto { namespace util::crypto {
// http://en.wikipedia.org/wiki/XXTEA // http://en.wikipedia.org/wiki/XXTEA
// 'corrected' block TEA // 'corrected' block TEA
class XXTEA { class XXTEA {
@ -36,7 +36,7 @@ namespace util { namespace crypto {
private: private:
key_t m_key; key_t m_key;
}; };
} } }
#endif #endif

View File

@ -337,7 +337,7 @@ void disable_fpe (void);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace debug { namespace util::debug {
void init (void); void init (void);
@ -388,7 +388,7 @@ namespace util { namespace debug {
(void)t; (void)t;
CHECK (is_valid (t)); CHECK (is_valid (t));
} }
} } }
#include "./debug.ipp" #include "./debug.ipp"

View File

@ -25,7 +25,7 @@
#include <limits> #include <limits>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace debug { namespace detail { namespace util::debug::detail {
void panic [[noreturn]] (const char *msg); void panic [[noreturn]] (const char *msg);
template <typename ...Args, size_t N> template <typename ...Args, size_t N>
@ -38,7 +38,7 @@ namespace util { namespace debug { namespace detail {
void not_implemented [[noreturn]] (const char *msg); void not_implemented [[noreturn]] (const char *msg);
void unreachable [[noreturn]] (const char *msg); void unreachable [[noreturn]] (const char *msg);
} } } }
// not_implemented/unreachable/panic must be callable from constexpr contexts. // not_implemented/unreachable/panic must be callable from constexpr contexts.
// but they rely on functions that aren't constexpr to perform the controlled // but they rely on functions that aren't constexpr to perform the controlled

View File

@ -19,7 +19,7 @@
#include <utility> #include <utility>
namespace util { namespace format { namespace detail { namespace util::format::detail {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
std::ostream& std::ostream&
operator<< (std::ostream &os, specifier::repr r) operator<< (std::ostream &os, specifier::repr r)
@ -72,4 +72,4 @@ namespace util { namespace format { namespace detail {
"length: " << s.length << "length: " << s.length <<
" }"; " }";
} }
} } } }

View File

@ -20,7 +20,7 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
namespace util { namespace format { namespace util::format {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// render a format string using the provided values. // render a format string using the provided values.
// //
@ -69,7 +69,7 @@ namespace util { namespace format {
error ("missing argument for specifier") error ("missing argument for specifier")
{ ; } { ; }
}; };
} } }
#include "format.ipp" #include "format.ipp"

View File

@ -23,7 +23,7 @@
#include <sstream> #include <sstream>
namespace util { namespace format { namespace detail { namespace util::format::detail {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// GCC: workaround which allows a throw to appear in constexpr codepaths // GCC: workaround which allows a throw to appear in constexpr codepaths
// that do not execute at compile time. See gcc#67371 // 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); return _render (os, first, last);
} }
} } } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace format { namespace util::format {
template <typename ...Args, size_t N> template <typename ...Args, size_t N>
std::string std::string
render (const char (&fmt)[N], const Args& ...args) render (const char (&fmt)[N], const Args& ...args)
@ -946,4 +946,4 @@ namespace util { namespace format {
detail::render (std::back_inserter (res), fmt, args...); detail::render (std::back_inserter (res), fmt, args...);
return res; return res;
} }
} } }

View File

@ -208,7 +208,7 @@ AABB<S,T>::operator== (const AABB<S,T> rhs) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util { namespace debug { namespace util::debug {
template <size_t S, typename T> template <size_t S, typename T>
struct validator<AABB<S,T>> { struct validator<AABB<S,T>> {
static bool is_valid (const AABB<S,T> &b) static bool is_valid (const AABB<S,T> &b)
@ -220,7 +220,7 @@ namespace util { namespace debug {
return true; return true;
} }
}; };
} } }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -235,7 +235,7 @@ util::geom::operator<< (std::ostream &os, util::geom::AABB<S,T> b)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define INSTANTIATE_S_T(S,T) \ #define INSTANTIATE_S_T(S,T) \
namespace util { namespace geom { template struct AABB<S,T>; } } \ namespace util::geom { template struct AABB<S,T>; } \
template bool util::debug::is_valid (const AABB<S,T>&); \ template bool util::debug::is_valid (const AABB<S,T>&); \
template std::ostream& util::geom::operator<< (std::ostream&, AABB<S,T>); template std::ostream& util::geom::operator<< (std::ostream&, AABB<S,T>);

View File

@ -23,7 +23,7 @@
#include <cstdint> #include <cstdint>
namespace util { namespace geom { namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
struct AABB { struct AABB {
AABB () = default; AABB () = default;
@ -64,7 +64,7 @@ namespace util { namespace geom {
typedef AABB<3,float> AABB3f; typedef AABB<3,float> AABB3f;
typedef AABB<3,unsigned> AABB3u; typedef AABB<3,unsigned> AABB3u;
typedef AABB<3,int> AABB3i; typedef AABB<3,int> AABB3i;
} } }
#include "aabb.ipp" #include "aabb.ipp"

View File

@ -26,7 +26,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace geom { namespace util::geom {
template <size_t S, typename T, typename G> template <size_t S, typename T, typename G>
struct sampler<S,T,AABB,G> { struct sampler<S,T,AABB,G> {
static point<S,T> static point<S,T>
@ -40,4 +40,4 @@ namespace util { namespace geom {
return p * (b.p1 - b.p0) + b.p0.template as<util::vector> (); return p * (b.p1 - b.p0) + b.p0.template as<util::vector> ();
} }
}; };
} } }

View File

@ -19,8 +19,8 @@
#include "../point.hpp" #include "../point.hpp"
namespace util { namespace geom { ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////// namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
struct cylinder { struct cylinder {
util::point<S,T> p0, p1; util::point<S,T> p0, p1;
@ -30,6 +30,6 @@ namespace util { namespace geom {
bool includes (util::point<S,T>) const; bool includes (util::point<S,T>) const;
}; };
} } }
#endif #endif

View File

@ -22,14 +22,14 @@
#include "../point.hpp" #include "../point.hpp"
#include "../vector.hpp" #include "../vector.hpp"
namespace util { namespace geom { namespace util::geom {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template <size_t S, typename T> template <size_t S, typename T>
struct ellipse { struct ellipse {
util::point<S,T> origin; util::point<S,T> origin;
util::vector<S,T> radius; util::vector<S,T> radius;
}; };
} } }
#include "ellipse.ipp" #include "ellipse.ipp"

View File

@ -26,7 +26,7 @@
#include <random> #include <random>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace geom { namespace util::geom {
template <typename T, template <size_t,typename> class K, typename G> template <typename T, template <size_t,typename> class K, typename G>
struct sampler<2,T,K,G> struct sampler<2,T,K,G>
{ {
@ -43,4 +43,4 @@ namespace util { namespace geom {
} * rho * k.radius + k.origin.template as<util::vector> (); } * rho * k.radius + k.origin.template as<util::vector> ();
} }
}; };
} } }

View File

@ -19,7 +19,7 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace geom { namespace util::geom {
template <size_t S, typename T> struct ray; template <size_t S, typename T> struct ray;
template <size_t S, typename T> struct plane; template <size_t S, typename T> struct plane;
template <size_t S, typename T> struct AABB; template <size_t S, typename T> struct AABB;
@ -28,6 +28,6 @@ namespace util { namespace geom {
template <size_t S, typename T> struct rect; template <size_t S, typename T> struct rect;
template <size_t S, typename T> struct cylinder; template <size_t S, typename T> struct cylinder;
template <size_t S, typename T> struct tri; template <size_t S, typename T> struct tri;
} } }
#endif #endif

View File

@ -21,7 +21,9 @@
#include <ostream> #include <ostream>
namespace util { namespace geom {
///////////////////////////////////////////////////////////////////////////////
namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
std::ostream& std::ostream&
operator<< (std::ostream&, AABB<S,T>); operator<< (std::ostream&, AABB<S,T>);
@ -33,6 +35,6 @@ namespace util { namespace geom {
template <size_t S, typename T> template <size_t S, typename T>
std::ostream& std::ostream&
operator<< (std::ostream&, sphere<S,T>); operator<< (std::ostream&, sphere<S,T>);
} } }
#endif #endif

View File

@ -20,7 +20,9 @@
#include "aabb.hpp" #include "aabb.hpp"
#include "../point.hpp" #include "../point.hpp"
namespace util { namespace geom {
///////////////////////////////////////////////////////////////////////////////
namespace util::geom {
template < template <
size_t S, size_t S,
typename T, typename T,
@ -87,6 +89,6 @@ namespace util { namespace geom {
> >
K<S,T> K<S,T>
scale (K<S,T>, T); scale (K<S,T>, T);
} } }
#endif #endif

View File

@ -20,7 +20,7 @@
#include "../point.hpp" #include "../point.hpp"
#include "../vector.hpp" #include "../vector.hpp"
namespace util { namespace geom { namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
struct plane { struct plane {
plane (util::point<S,T> p, plane (util::point<S,T> p,
@ -33,6 +33,6 @@ namespace util { namespace geom {
typedef plane<2,float> plane2f; typedef plane<2,float> plane2f;
typedef plane<3,float> plane3f; typedef plane<3,float> plane3f;
} } }
#endif #endif

View File

@ -23,7 +23,9 @@
#include "../vector.hpp" #include "../vector.hpp"
#include "../point.hpp" #include "../point.hpp"
namespace util { namespace geom {
///////////////////////////////////////////////////////////////////////////////
namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
struct ray { struct ray {
ray (point<S,T> origin, ray (point<S,T> origin,
@ -50,6 +52,6 @@ namespace util { namespace geom {
typedef ray<2,float> ray2f; typedef ray<2,float> ray2f;
typedef ray<3,float> ray3f; typedef ray<3,float> ray3f;
} } }
#endif #endif

View File

@ -19,7 +19,9 @@
#include "../point.hpp" #include "../point.hpp"
namespace util { namespace geom {
///////////////////////////////////////////////////////////////////////////////
namespace util::geom {
template < template <
size_t S, size_t S,
typename T, typename T,
@ -41,7 +43,7 @@ namespace util { namespace geom {
{ {
return sampler<S,T,K,G>::fn (k, g); return sampler<S,T,K,G>::fn (k, g);
} }
} } }
#include "sample.ipp" #include "sample.ipp"

View File

@ -22,7 +22,7 @@
#include "ops.hpp" #include "ops.hpp"
namespace util { namespace geom { namespace util::geom {
// use rejection sampling by default // use rejection sampling by default
template < template <
size_t S, size_t S,
@ -41,5 +41,5 @@ namespace util { namespace geom {
return p; return p;
} }
} }
} } }

View File

@ -19,7 +19,9 @@
#include "../point.hpp" #include "../point.hpp"
namespace util { namespace geom {
///////////////////////////////////////////////////////////////////////////////
namespace util::geom {
template <size_t S, typename T> template <size_t S, typename T>
struct sphere { struct sphere {
point<S,T> centre; point<S,T> centre;
@ -28,6 +30,6 @@ namespace util { namespace geom {
typedef sphere<2,float> sphere2f; typedef sphere<2,float> sphere2f;
typedef sphere<3,float> sphere3f; typedef sphere<3,float> sphere3f;
} } }
#endif #endif

View File

@ -22,9 +22,9 @@
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
namespace util { namespace hash { namespace util::hash {
uint32_t mix (uint32_t v) { return wang (v); } uint32_t mix (uint32_t v) { return wang (v); }
uint64_t mix (uint64_t v) { return wang (v); } uint64_t mix (uint64_t v) { return wang (v); }
} } }
#endif #endif

View File

@ -23,11 +23,11 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class adler32 : public fletcher<uint32_t> { class adler32 : public fletcher<uint32_t> {
public: public:
adler32 (); adler32 ();
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class bsdsum { class bsdsum {
public: public:
using digest_t = uint16_t; using digest_t = uint16_t;
@ -40,6 +40,6 @@ namespace util { namespace hash {
private: private:
digest_t m_accum; digest_t m_accum;
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class crc32 { class crc32 {
public: public:
using digest_t = uint32_t; using digest_t = uint32_t;
@ -36,7 +36,7 @@ namespace util { namespace hash {
digest_t digest (void) const; digest_t digest (void) const;
}; };
}
} }
#endif #endif

View File

@ -21,12 +21,12 @@
#include <cstdint> #include <cstdint>
// Zilong Tan's FastHash, via George Marsaglia's "Xorshift RNGs" // 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); uint64_t mix (uint64_t);
uint32_t hash32 (const void *restrict data, size_t len, uint32_t seed); 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); uint64_t hash64 (const void *restrict data, size_t len, uint64_t seed);
} } } }
#endif #endif

View File

@ -24,7 +24,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
template <typename DIGEST> template <typename DIGEST>
class fletcher { class fletcher {
public: public:
@ -51,7 +51,7 @@ namespace util { namespace hash {
const state_t m_initial; const state_t m_initial;
state_t m_state; state_t m_state;
}; };
} } }
#endif #endif

View File

@ -20,10 +20,10 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace util { namespace hash { namespace util::hash {
// Fast and general hashing using FNV-1a // Fast and general hashing using FNV-1a
uint32_t fnv1a32 (const void *restrict, size_t); uint32_t fnv1a32 (const void *restrict, size_t);
uint64_t fnv1a64 (const void *restrict, size_t); uint64_t fnv1a64 (const void *restrict, size_t);
} } }
#endif #endif

View File

@ -27,7 +27,7 @@
// Forward declerations of class based hashes // Forward declerations of class based hashes
namespace util { namespace hash { namespace util::hash {
template <class T> class HMAC; template <class T> class HMAC;
// checksums // checksums
@ -49,6 +49,6 @@ namespace util { namespace hash {
class RIPEMD; class RIPEMD;
class SHA1; class SHA1;
class SHA256; class SHA256;
} } }
#endif #endif

View File

@ -21,7 +21,7 @@
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
namespace util { namespace hash { namespace util::hash {
template <class T> template <class T>
/// RFC 2104 key-hashing for message authentication /// RFC 2104 key-hashing for message authentication
class HMAC { class HMAC {
@ -42,6 +42,6 @@ namespace util { namespace hash {
T m_hash; T m_hash;
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
#include <cstdint> #include <cstdint>
namespace util { namespace hash { namespace util::hash {
/// HMAC one-time password (RFC 4226) /// HMAC one-time password (RFC 4226)
class HOTP { class HOTP {
public: public:
@ -38,6 +38,6 @@ namespace util { namespace hash {
uint64_t m_counter; uint64_t m_counter;
HMAC<SHA1> m_hash; HMAC<SHA1> m_hash;
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class MD2 { class MD2 {
public: public:
typedef std::array<uint8_t,16> digest_t; typedef std::array<uint8_t,16> digest_t;
@ -45,6 +45,6 @@ namespace util { namespace hash {
uint8_t C[16]; uint8_t C[16];
uint8_t X[48]; uint8_t X[48];
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class MD4 { class MD4 {
public: public:
typedef std::array<uint8_t,16> digest_t; typedef std::array<uint8_t,16> digest_t;
@ -48,6 +48,6 @@ namespace util { namespace hash {
uint8_t Xb[64]; uint8_t Xb[64];
}; };
}; };
} } }
#endif #endif

View File

@ -23,7 +23,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class MD5 { class MD5 {
public: public:
typedef std::array<uint8_t,16> digest_t; typedef std::array<uint8_t,16> digest_t;
@ -51,6 +51,6 @@ namespace util { namespace hash {
uint8_t Xb[64]; uint8_t Xb[64];
}; };
}; };
} } }
#endif #endif

View File

@ -18,11 +18,13 @@
#include "../../debug.hpp" #include "../../debug.hpp"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util::hash::murmur {
template <>
uint32_t uint32_t
util::hash::murmur::tail (const uint32_t *restrict data, size_t len) tail<uint32_t> (const uint8_t *restrict bytes, size_t len)
{ {
auto bytes = reinterpret_cast<const uint8_t*> (data);
uint32_t h = 0; uint32_t h = 0;
switch (len % sizeof (uint32_t)) { switch (len % sizeof (uint32_t)) {
@ -37,13 +39,15 @@ util::hash::murmur::tail (const uint32_t *restrict data, size_t len)
return h; return h;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util::hash::murmur {
template <>
uint64_t uint64_t
util::hash::murmur::tail (const uint64_t *restrict data, size_t len) tail<uint64_t> (const uint8_t *restrict bytes, size_t len)
{ {
auto bytes = reinterpret_cast<const uint8_t*> (data);
uint64_t h = 0; uint64_t h = 0;
switch (len % sizeof (uint64_t)) { switch (len % sizeof (uint64_t)) {
@ -62,13 +66,15 @@ util::hash::murmur::tail (const uint64_t *restrict data, size_t len)
return h; return h;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util::hash::murmur {
template <>
std::array<uint32_t,4> std::array<uint32_t,4>
util::hash::murmur::tail_array (const uint32_t *restrict data, size_t len) tail_array<uint32_t> (const uint8_t *restrict bytes, size_t len)
{ {
auto bytes = reinterpret_cast<const uint8_t*> (data);
std::array<uint32_t,4> result {0,0,0,0}; std::array<uint32_t,4> result {0,0,0,0};
switch (len % 16) { switch (len % 16) {
@ -95,13 +101,15 @@ util::hash::murmur::tail_array (const uint32_t *restrict data, size_t len)
return result; return result;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace util::hash::murmur {
template <>
std::array<uint64_t,2> std::array<uint64_t,2>
util::hash::murmur::tail_array (const uint64_t *restrict data, size_t len) tail_array<uint64_t> (const uint8_t *restrict bytes, size_t len)
{ {
auto bytes = reinterpret_cast<const uint8_t*> (data);
std::array<uint64_t,2> result {0, 0}; std::array<uint64_t,2> result {0, 0};
switch(len & 15) switch(len & 15)
@ -130,5 +138,4 @@ util::hash::murmur::tail_array (const uint64_t *restrict data, size_t len)
return result; return result;
} }
}

View File

@ -19,13 +19,12 @@
#include <cstdint> #include <cstdint>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace murmur { namespace util::hash::murmur {
uint32_t tail (const uint32_t *restrict data, size_t len); template <typename T>
uint64_t tail (const uint64_t *restrict data, size_t len); T
tail (const uint8_t *restrict data, size_t len);
std::array<uint32_t,4> template <typename T>
tail_array (const uint32_t *restrict data, size_t len); std::array<T,16/sizeof(T)>
tail_array (const uint8_t *restrict data, size_t len);
std::array<uint64_t,2> }
tail_array (const uint64_t *restrict data, size_t len);
} } }

View File

@ -42,7 +42,7 @@ util::hash::murmur1::hash_32 (const void *restrict data,
CHECK (data); CHECK (data);
static const uint32_t m = 0xc6a4a793; static const uint32_t m = 0xc6a4a793;
uint32_t h = seed ^ (uint32_t (len) * m); uint32_t h = seed ^ ((len & 0xffffffff) * m);
// mix the body // mix the body
auto cursor = reinterpret_cast<const uint32_t*> (data); auto cursor = reinterpret_cast<const uint32_t*> (data);
@ -52,7 +52,7 @@ util::hash::murmur1::hash_32 (const void *restrict data,
// mix the tail // mix the tail
if (len % sizeof (uint32_t)) if (len % sizeof (uint32_t))
h = mix (h, murmur::tail (cursor, len)); h = mix (h, murmur::tail<uint32_t> (reinterpret_cast<const uint8_t*> (cursor), len));
// finalise // finalise
h *= m; h ^= h >> 10; h *= m; h ^= h >> 10;

View File

@ -21,9 +21,9 @@
#include <cstddef> #include <cstddef>
// Austin Appleby's MumurHash1 // Austin Appleby's MumurHash1
namespace util { namespace hash { namespace murmur1 { namespace util::hash::murmur1 {
uint32_t mix (uint32_t, uint32_t); uint32_t mix (uint32_t, uint32_t);
uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed);
} } } }
#endif #endif

View File

@ -31,7 +31,7 @@ util::hash::murmur2::hash_32 (const void *restrict key,
// setup // setup
constexpr auto m = detail::constants<uint32_t>::m; constexpr auto m = detail::constants<uint32_t>::m;
uint32_t h = seed ^ uint32_t (len); uint32_t h = seed ^ (len & 0xffffffff);
// body // body
auto cursor = reinterpret_cast<const uint32_t*> (key); auto cursor = reinterpret_cast<const uint32_t*> (key);
@ -41,7 +41,7 @@ util::hash::murmur2::hash_32 (const void *restrict key,
// tail // tail
if (len % sizeof (uint32_t)) { if (len % sizeof (uint32_t)) {
h ^= murmur::tail (cursor, len); h ^= murmur::tail<uint32_t> (reinterpret_cast<const uint8_t*> (cursor), len);
h *= m; h *= m;
} }
@ -74,7 +74,7 @@ util::hash::murmur2::hash_64 (const void *restrict key,
// tail // tail
if (len % sizeof (uint64_t)) { if (len % sizeof (uint64_t)) {
h ^= murmur::tail (cursor, len); h ^= murmur::tail<uint64_t> (reinterpret_cast<const uint8_t*> (cursor), len);
h *= m; h *= m;
} }

View File

@ -23,13 +23,13 @@
// Austin Appleby's MumurHash2, and MurmurHash64A. The exhaustive list of // Austin Appleby's MumurHash2, and MurmurHash64A. The exhaustive list of
// variants is deliberately not provided. You can damn well align your data or // variants is deliberately not provided. You can damn well align your data or
// fix the algorithm. // fix the algorithm.
namespace util { namespace hash { namespace murmur2 { namespace util::hash::murmur2 {
constexpr uint32_t mix (uint32_t, uint32_t); constexpr uint32_t mix (uint32_t, uint32_t);
constexpr uint64_t mix (uint64_t, uint64_t); constexpr uint64_t mix (uint64_t, uint64_t);
uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); 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); uint64_t hash_64 (const void *restrict data, size_t len, uint64_t seed);
} } } }
#include "./murmur2.ipp" #include "./murmur2.ipp"

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace murmur2 { namespace detail { namespace util::hash::murmur2::detail {
template <typename T> struct constants; template <typename T> struct constants;
template <> template <>
@ -36,7 +36,7 @@ namespace util { namespace hash { namespace murmur2 { namespace detail {
static const uint64_t m = 0xc6a4a7935bd1e995; static const uint64_t m = 0xc6a4a7935bd1e995;
static const int64_t r = 47; static const int64_t r = 47;
}; };
} } } } }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

View File

@ -22,6 +22,18 @@
#include <algorithm> #include <algorithm>
///////////////////////////////////////////////////////////////////////////////
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 // Finalization mix - force all bits of a hash block to avalanche
uint32_t uint32_t
@ -67,10 +79,10 @@ util::hash::murmur3::hash_32(const void *restrict key,
//---------- //----------
// body // body
auto cursor = reinterpret_cast<const uint32_t *> (data); auto cursor = data;
auto last = cursor + nblocks; auto last = cursor + nblocks * sizeof (uint32_t);
for (; cursor < last; ++cursor) { for (; cursor < last; cursor += sizeof (uint32_t)) {
uint32_t k1 = *cursor; uint32_t k1 = read_u32 (cursor);
k1 *= c1; k1 *= c1;
k1 = util::rotatel (k1, 15); k1 = util::rotatel (k1, 15);
@ -85,7 +97,7 @@ util::hash::murmur3::hash_32(const void *restrict key,
//---------- //----------
// tail // tail
if (len % sizeof (uint32_t)) { if (len % sizeof (uint32_t)) {
uint32_t k1 = 0 ^ murmur::tail (cursor, len); uint32_t k1 = 0 ^ murmur::tail<uint32_t> (cursor, len);
k1 *= c1; k1 *= c1;
k1 = util::rotatel (k1, 15); k1 = util::rotatel (k1, 15);
@ -208,7 +220,7 @@ hash_128 (const void *restrict key,
// process the tail // process the tail
if (len % 16) { if (len % 16) {
auto k = util::hash::murmur::tail_array (cursor, len); auto k = util::hash::murmur::tail_array<T> (reinterpret_cast<const uint8_t*> (cursor), len);
for (auto &v: k) for (auto &v: k)
v = 0 ^ v; v = 0 ^ v;

View File

@ -22,14 +22,14 @@
#include <cstdint> #include <cstdint>
// Austin Appleby's MurmurHash3 // Austin Appleby's MurmurHash3
namespace util { namespace hash { namespace murmur3 { namespace util::hash::murmur3 {
uint32_t mix (uint32_t); uint32_t mix (uint32_t);
uint64_t mix (uint64_t); uint64_t mix (uint64_t);
uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed); uint32_t hash_32 (const void *restrict data, size_t len, uint32_t seed);
std::array<uint32_t,4> hash_128_x86 (const void *restrict data, size_t len, uint32_t seed); std::array<uint32_t,4> hash_128_x86 (const void *restrict data, size_t len, uint32_t seed);
std::array<uint64_t,2> hash_128_x64 (const void *restrict data, size_t len, uint32_t seed); std::array<uint64_t,2> hash_128_x64 (const void *restrict data, size_t len, uint32_t seed);
} } } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class RIPEMD { class RIPEMD {
public: public:
typedef std::array<uint8_t,20> digest_t; typedef std::array<uint8_t,20> digest_t;
@ -53,6 +53,6 @@ namespace util { namespace hash {
size_t size; size_t size;
} m_buffer; } m_buffer;
}; };
} } }
#endif #endif

View File

@ -24,7 +24,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class SHA1 { class SHA1 {
public: public:
typedef std::array<uint8_t,20> digest_t; typedef std::array<uint8_t,20> digest_t;
@ -59,6 +59,6 @@ namespace util { namespace hash {
uint32_t W[16 +64 ]; uint32_t W[16 +64 ];
}; };
}; };
} } }
#endif #endif

View File

@ -23,7 +23,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
class SHA256 { class SHA256 {
public: public:
typedef std::array<uint8_t,32> digest_t; typedef std::array<uint8_t,32> digest_t;
@ -50,6 +50,6 @@ namespace util { namespace hash {
std::array<uint8_t, 64> C; std::array<uint8_t, 64> C;
}; };
}; };
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace hash { namespace util::hash {
//template <class H, class InputT> //template <class H, class InputT>
template <class H, typename ...Args> template <class H, typename ...Args>
typename H::digest_t typename H::digest_t
@ -38,6 +38,6 @@ namespace util { namespace hash {
return h.digest (); return h.digest ();
} }
} } }
#endif #endif

View File

@ -19,11 +19,11 @@
#include <cstdint> #include <cstdint>
namespace util { namespace hash { namespace util::hash {
// Thomas Wang's integer mixing functions, ca 2007 // Thomas Wang's integer mixing functions, ca 2007
constexpr uint32_t wang (uint32_t); constexpr uint32_t wang (uint32_t);
constexpr uint64_t wang (uint64_t); constexpr uint64_t wang (uint64_t);
} } }
#include "wang.ipp" #include "wang.ipp"

View File

@ -28,7 +28,7 @@
#include <fcntl.h> #include <fcntl.h>
namespace util { namespace util {
namespace detail { namespace posix { namespace detail::posix {
class mapped_file { class mapped_file {
public: public:
mapped_file (const std::experimental::filesystem::path&, int fflags = O_RDONLY | O_BINARY, int mflags = PROT_READ); 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; uint8_t *m_data;
size_t m_size; size_t m_size;
}; };
} } }
typedef detail::posix::mapped_file mapped_file; typedef detail::posix::mapped_file mapped_file;
} }

View File

@ -51,7 +51,7 @@ enum : int {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// implementation definitions // implementation definitions
namespace util { namespace util {
namespace detail { namespace win32 { namespace detail::win32 {
class mapped_file { class mapped_file {
public: public:
mapped_file (::util::win32::handle &&, mapped_file (::util::win32::handle &&,
@ -97,7 +97,7 @@ namespace util {
std::unique_ptr<uint8_t,BOOL(*)(LPCVOID)> m_data; std::unique_ptr<uint8_t,BOOL(*)(LPCVOID)> m_data;
uint64_t m_size; uint64_t m_size;
}; };
} } }
typedef detail::win32::mapped_file mapped_file; typedef detail::win32::mapped_file mapped_file;
} }

View File

@ -22,7 +22,9 @@
#include "../view.hpp" #include "../view.hpp"
namespace json { namespace flat {
///////////////////////////////////////////////////////////////////////////////
namespace json::flat {
enum class type { enum class type {
UNKNOWN, UNKNOWN,
@ -53,6 +55,6 @@ namespace json { namespace flat {
std::vector<item<T>> parse (util::view<T> data); std::vector<item<T>> parse (util::view<T> data);
std::ostream& operator<< (std::ostream&, type); std::ostream& operator<< (std::ostream&, type);
} } }
#endif #endif

View File

@ -21,7 +21,9 @@
#include <experimental/filesystem> #include <experimental/filesystem>
namespace json { namespace schema {
///////////////////////////////////////////////////////////////////////////////
namespace json::schema {
// Validate the json tree using the provide schema object or path. // Validate the json tree using the provide schema object or path.
// //
// Note that the data object being validated may be altered in the process // 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. // 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 json::tree::object &schema);
void validate (json::tree::node &data, const std::experimental::filesystem::path &schema); void validate (json::tree::node &data, const std::experimental::filesystem::path &schema);
} } }
#endif #endif

View File

@ -377,7 +377,7 @@ json::tree::node::as_chars (void) const&
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace json { namespace tree { namespace json::tree {
#if defined(__clang__) #if defined(__clang__)
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -445,7 +445,7 @@ namespace json { namespace tree {
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
} } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -1009,7 +1009,7 @@ json::tree::operator<< (std::ostream &os, const json::tree::node &n)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// to_json // to_json
namespace json { namespace tree { namespace json::tree {
template <> template <>
std::unique_ptr<node> std::unique_ptr<node>
io<bool>::serialise (const bool &b) { io<bool>::serialise (const bool &b) {
@ -1057,4 +1057,4 @@ namespace json { namespace tree {
io<float>::serialise (const float &f) { io<float>::serialise (const float &f) {
return std::unique_ptr<node> (new number (f)); return std::unique_ptr<node> (new number (f));
} }
} } }

View File

@ -32,7 +32,8 @@
#include <experimental/filesystem> #include <experimental/filesystem>
namespace json { namespace tree { ///////////////////////////////////////////////////////////////////////////////
namespace json::tree {
enum type_t { enum type_t {
OBJECT, OBJECT,
ARRAY, ARRAY,
@ -354,8 +355,10 @@ namespace json { namespace tree {
static std::unique_ptr<json::tree::node> serialise (const T&); static std::unique_ptr<json::tree::node> serialise (const T&);
static T deserialise (const json::tree::node&); static T deserialise (const json::tree::node&);
}; };
} } }
///////////////////////////////////////////////////////////////////////////////
template <typename T, class ...Args> template <typename T, class ...Args>
std::unique_ptr<json::tree::node> std::unique_ptr<json::tree::node>
to_json (const T &t, Args&&... args) to_json (const T &t, Args&&... args)
@ -365,6 +368,8 @@ to_json (const T &t, Args&&... args)
); );
} }
///////////////////////////////////////////////////////////////////////////////
template <typename T, class ...Args> template <typename T, class ...Args>
T T
from_json (const json::tree::node &n, Args&&... args) from_json (const json::tree::node &n, Args&&... args)
@ -375,5 +380,3 @@ from_json (const json::tree::node &n, Args&&... args)
} }
#endif #endif

View File

@ -22,7 +22,7 @@
#include <experimental/filesystem> #include <experimental/filesystem>
namespace util { namespace util {
namespace detail { namespace win32 { namespace detail::win32 {
class library { class library {
public: public:
library (const std::experimental::filesystem::path&); library (const std::experimental::filesystem::path&);
@ -33,7 +33,7 @@ namespace util {
private: private:
HMODULE m_handle; HMODULE m_handle;
}; };
} } }
typedef detail::win32::library library; typedef detail::win32::library library;
} }

View File

@ -19,7 +19,7 @@
#include <cstddef> #include <cstddef>
namespace util { namespace memory { namespace buffer { namespace util::memory::buffer {
// buffer size is advisory and will likely depend on page size. the user // 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 // must check the size after creation if this field is important for
// their usage. // their usage.
@ -50,6 +50,6 @@ namespace util { namespace memory { namespace buffer {
char *m_begin, *m_end; char *m_begin, *m_end;
}; };
} } } }
#endif #endif

View File

@ -19,7 +19,7 @@
#include <cstddef> #include <cstddef>
namespace util { namespace memory { namespace buffer { namespace util::memory::buffer {
class paged { class paged {
public: public:
using value_type = char; using value_type = char;
@ -54,6 +54,6 @@ namespace util { namespace memory { namespace buffer {
char *m_begin, *m_end, *m_cursor; char *m_begin, *m_end, *m_cursor;
size_t m_window; size_t m_window;
}; };
} } } }
#endif #endif

View File

@ -19,7 +19,7 @@
#include <functional> #include <functional>
namespace util { namespace memory { namespace util::memory {
template <typename T> template <typename T>
class func_deleter { class func_deleter {
public: public:
@ -57,6 +57,6 @@ namespace util { namespace memory {
private: private:
U& m_owner; U& m_owner;
}; };
} } }
#endif #endif

View File

@ -19,8 +19,8 @@
#include <cstddef> #include <cstddef>
namespace util { namespace memory { namespace util::memory {
size_t pagesize (void); size_t pagesize (void);
} } }
#endif #endif

View File

@ -22,7 +22,7 @@
#include <functional> #include <functional>
#include <experimental/filesystem> #include <experimental/filesystem>
namespace util { namespace posix { namespace util::posix {
struct dir { struct dir {
public: public:
explicit dir (const std::experimental::filesystem::path&); explicit dir (const std::experimental::filesystem::path&);
@ -46,7 +46,7 @@ namespace util { namespace posix {
private: private:
DIR *m_handle; DIR *m_handle;
}; };
} } }
#include "./dir.ipp" #include "./dir.ipp"

View File

@ -21,7 +21,7 @@
#include <type_traits> #include <type_traits>
namespace util { namespace rand { namespace util::rand {
/// linear congruential generator /// linear congruential generator
/// ///
/// T: output/state type /// T: output/state type
@ -50,6 +50,6 @@ namespace util { namespace rand {
// glibc: typedef lcg<uint32_t, pow2(31), 1103515245, 12345> lcg_t; // glibc: typedef lcg<uint32_t, pow2(31), 1103515245, 12345> lcg_t;
using lcg_t = lcg<uint64_t,0u,6364136223846793005ul, 1ul>; using lcg_t = lcg<uint64_t,0u,6364136223846793005ul, 1ul>;
} } }
#endif #endif

View File

@ -19,7 +19,7 @@
#include <cstdint> #include <cstdint>
namespace util { namespace rand { namespace util::rand {
// multiply-with-carry style generator suitable for rapid seeking and // multiply-with-carry style generator suitable for rapid seeking and
// GPU generation. // GPU generation.
// //
@ -37,7 +37,7 @@ namespace util { namespace rand {
private: private:
uint64_t m_state; uint64_t m_state;
}; };
} } }
#endif #endif

View File

@ -17,7 +17,7 @@
#ifndef __UTIL_RAND_XORSHIFT_HPP #ifndef __UTIL_RAND_XORSHIFT_HPP
#define __UTIL_RAND_XORSHIFT_HPP #define __UTIL_RAND_XORSHIFT_HPP
namespace util { namespace rand { namespace util::rand {
// implements a naive xorshift random generator. // implements a naive xorshift random generator.
// //
// * does not comply with the c++11 rng class requirements // * does not comply with the c++11 rng class requirements
@ -40,6 +40,6 @@ namespace util { namespace rand {
private: private:
T m_state; T m_state;
}; };
} } }
#endif #endif

View File

@ -345,7 +345,7 @@ util::operator<< (std::ostream &os, const util::region<S,T> &rhs) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace util { namespace debug { namespace util::debug {
template <size_t S, typename T> template <size_t S, typename T>
struct validator<util::region<S,T>> { struct validator<util::region<S,T>> {
static bool is_valid (const util::region<S,T> &r) static bool is_valid (const util::region<S,T> &r)
@ -353,7 +353,7 @@ namespace util { namespace debug {
return util::debug::is_valid (r.p) && util::debug::is_valid (r.e); return util::debug::is_valid (r.p) && util::debug::is_valid (r.e);
} }
}; };
} } }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -21,7 +21,7 @@
#include <cmath> #include <cmath>
namespace util { namespace roots { namespace util::roots {
/// find a root of a function using the bisection method /// find a root of a function using the bisection method
/// ///
/// the user is responsible for ensuring there is in fact a root. there /// the user is responsible for ensuring there is in fact a root. there
@ -64,6 +64,6 @@ namespace util { namespace roots {
// valid mathematically. // valid mathematically.
return (a + b) / T{2}; return (a + b) / T{2};
} }
} } }
#endif #endif

View File

@ -19,7 +19,7 @@
#include <functional> #include <functional>
namespace util { namespace TAP { namespace util::TAP {
/// A simple TAP (Test Anything Protocol) test case output /// A simple TAP (Test Anything Protocol) test case output
class logger { class logger {
public: public:
@ -84,7 +84,7 @@ namespace util { namespace TAP {
int m_status; int m_status;
size_t m_size; size_t m_size;
}; };
} } }
#include "tap.ipp" #include "tap.ipp"

View File

@ -19,7 +19,7 @@
#include <ostream> #include <ostream>
namespace util { namespace term { namespace util::term {
bool has_csi_support (void); bool has_csi_support (void);
namespace csi { namespace csi {
@ -63,6 +63,6 @@ namespace util { namespace term {
std::ostream& operator<< (std::ostream&, code); std::ostream& operator<< (std::ostream&, code);
std::ostream& operator<< (std::ostream&, graphics); std::ostream& operator<< (std::ostream&, graphics);
} }
} } }
#endif #endif

View File

@ -24,7 +24,7 @@
#include <type_traits> #include <type_traits>
namespace util { namespace tuple { namespace util::tuple {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/// call a provided object with type_tag<T> for each type in a tuple /// call a provided object with type_tag<T> for each type in a tuple
template < template <
@ -163,7 +163,7 @@ namespace util { namespace tuple {
>::type... >::type...
> type; > type;
}; };
} } }
#endif #endif

View File

@ -16,7 +16,7 @@
#include <windows.h> #include <windows.h>
namespace util { namespace win32 { namespace util::win32 {
struct handle { struct handle {
handle (); handle ();
explicit handle (HANDLE&&); explicit handle (HANDLE&&);
@ -36,4 +36,4 @@ namespace util { namespace win32 {
private: private:
HANDLE m_native; HANDLE m_native;
}; };
} } }

View File

@ -22,7 +22,7 @@
#include <set> #include <set>
#include <string> #include <string>
namespace util { namespace win32 { namespace util::win32 {
class key { class key {
public: public:
key (HKEY root, const char *child, REGSAM rights = KEY_READ); key (HKEY root, const char *child, REGSAM rights = KEY_READ);
@ -37,6 +37,6 @@ namespace util { namespace win32 {
private: private:
HKEY m_handle; HKEY m_handle;
}; };
} } }
#endif #endif