From 8ddbccc94f86ba17008692c5be1d19fb8d50ebef Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 13 Jul 2015 20:07:14 +0100 Subject: [PATCH] namespace octa -> namespace ostd --- octa/algorithm.hh | 26 +++++++++++++------------- octa/array.hh | 8 ++++---- octa/atomic.hh | 2 +- octa/format.hh | 10 +++++----- octa/functional.hh | 6 +++--- octa/initializer_list.hh | 8 ++++---- octa/internal/hashtable.hh | 4 ++-- octa/internal/tuple.hh | 4 ++-- octa/io.hh | 12 ++++++------ octa/map.hh | 6 +++--- octa/maybe.hh | 6 +++--- octa/memory.hh | 8 ++++---- octa/new.hh | 4 ++-- octa/platform.hh | 2 +- octa/range.hh | 4 ++-- octa/set.hh | 6 +++--- octa/stream.hh | 2 +- octa/string.hh | 26 +++++++++++++------------- octa/tuple.hh | 4 ++-- octa/type_traits.hh | 4 ++-- octa/types.hh | 2 +- octa/utility.hh | 6 +++--- octa/vector.hh | 10 +++++----- src/new.cc | 4 ++-- tests/array.cc | 2 +- tests/utility.cc | 2 +- tests/vector.cc | 2 +- 27 files changed, 90 insertions(+), 90 deletions(-) diff --git a/octa/algorithm.hh b/octa/algorithm.hh index f2d8e37..1a26062 100644 --- a/octa/algorithm.hh +++ b/octa/algorithm.hh @@ -13,7 +13,7 @@ #include "octa/utility.hh" #include "octa/initializer_list.hh" -namespace octa { +namespace ostd { /* partitioning */ @@ -153,7 +153,7 @@ template inline R min_element(R range) { R r = range; for (; !range.empty(); range.pop_front()) - if (octa::min(r.front(), range.front()) == range.front()) + if (ostd::min(r.front(), range.front()) == range.front()) r = range; return r; } @@ -161,7 +161,7 @@ template inline R min_element(R range, C compare) { R r = range; for (; !range.empty(); range.pop_front()) - if (octa::min(r.front(), range.front(), compare) == range.front()) + if (ostd::min(r.front(), range.front(), compare) == range.front()) r = range; return r; } @@ -170,7 +170,7 @@ template inline R max_element(R range) { R r = range; for (; !range.empty(); range.pop_front()) - if (octa::max(r.front(), range.front()) == range.front()) + if (ostd::max(r.front(), range.front()) == range.front()) r = range; return r; } @@ -178,40 +178,40 @@ template inline R max_element(R range, C compare) { R r = range; for (; !range.empty(); range.pop_front()) - if (octa::max(r.front(), range.front(), compare) == range.front()) + if (ostd::max(r.front(), range.front(), compare) == range.front()) r = range; return r; } template inline T min(std::initializer_list il) { - return octa::min_element(octa::iter(il)).front(); + return ostd::min_element(ostd::iter(il)).front(); } template inline T min(std::initializer_list il, C compare) { - return octa::min_element(octa::iter(il), compare).front(); + return ostd::min_element(ostd::iter(il), compare).front(); } template inline T max(std::initializer_list il) { - return octa::max_element(octa::iter(il)).front(); + return ostd::max_element(ostd::iter(il)).front(); } template inline T max(std::initializer_list il, C compare) { - return octa::max_element(octa::iter(il), compare).front(); + return ostd::max_element(ostd::iter(il), compare).front(); } /* clamp */ template inline T clamp(const T &v, const U &lo, const U &hi) { - return octa::max(T(lo), octa::min(v, T(hi))); + return ostd::max(T(lo), ostd::min(v, T(hi))); } template inline T clamp(const T &v, const U &lo, const U &hi, C compare) { - return octa::max(T(lo), octa::min(v, T(hi), compare), compare); + return ostd::max(T(lo), ostd::min(v, T(hi), compare), compare); } /* lexicographical compare */ @@ -396,7 +396,7 @@ Pair swap_ranges(R1 range1, R2 range2) { range1.pop_front(); range2.pop_front(); } - return octa::make_pair(range1, range2); + return ostd::make_pair(range1, range2); } template @@ -590,6 +590,6 @@ FilterRange> filter(R range, P pred) { return FilterRange(range, pred); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/array.hh b/octa/array.hh index 28b6864..f8ae6cb 100644 --- a/octa/array.hh +++ b/octa/array.hh @@ -13,11 +13,11 @@ #include "octa/string.hh" #include "octa/internal/tuple.hh" -namespace octa { +namespace ostd { template struct Array { - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Value = T; using Reference = T &; @@ -70,7 +70,7 @@ struct Array { } void swap(Array &v) { - octa::swap_ranges(iter(), v.iter()); + ostd::swap_ranges(iter(), v.iter()); } T p_buf[(N > 0) ? N : 1]; @@ -129,6 +129,6 @@ inline bool operator>=(const Array &x, const Array &y) { return !(x < y); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/atomic.hh b/octa/atomic.hh index a50d5b6..3fb76a9 100644 --- a/octa/atomic.hh +++ b/octa/atomic.hh @@ -12,7 +12,7 @@ #include "octa/types.hh" #include "octa/type_traits.hh" -namespace octa { +namespace ostd { enum class MemoryOrder { relaxed = 0, diff --git a/octa/format.hh b/octa/format.hh index d025d02..ecba014 100644 --- a/octa/format.hh +++ b/octa/format.hh @@ -16,7 +16,7 @@ #include "octa/utility.hh" #include "octa/internal/tuple.hh" -namespace octa { +namespace ostd { enum FormatFlags { FMT_FLAG_DASH = 1 << 0, @@ -519,7 +519,7 @@ namespace detail { const T &val, EnableIf::value, bool> = true) { - auto range = octa::iter(val); + auto range = ostd::iter(val); if (range.empty()) return 0; Ptrdiff ret = 0; Size fmtn = 0; @@ -553,7 +553,7 @@ namespace detail { } template - static True test_fmt_tostr(decltype(octa::to_string(declval())) *); + static True test_fmt_tostr(decltype(ostd::to_string(declval())) *); template static False test_fmt_tostr(...); template @@ -776,7 +776,7 @@ namespace detail { assert(false && "custom objects need '%s' format"); return -1; } - return write(writer, false, octa::to_string(val)); + return write(writer, false, ostd::to_string(val)); } /* custom format case */ @@ -938,6 +938,6 @@ Ptrdiff format(R &&writer, const AnyString &fmt, const A &...args) { return format(writer, fmtn, fmt.data(), args...); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/functional.hh b/octa/functional.hh index 8aad5f6..3ccbf61 100644 --- a/octa/functional.hh +++ b/octa/functional.hh @@ -14,7 +14,7 @@ #include "octa/utility.hh" #include "octa/type_traits.hh" -namespace octa { +namespace ostd { /* basic function objects */ @@ -797,7 +797,7 @@ struct Function: detail::FunctionBase { f.p_stor.manager->call_move_and_destroyf(tmp, move(f.p_stor)); p_stor.manager->call_move_and_destroyf(f.p_stor, move(p_stor)); tmp.manager->call_move_and_destroyf(p_stor, move(tmp)); - octa::swap(p_call, f.p_call); + ostd::swap(p_call, f.p_call); } operator bool() const { return p_call != nullptr; } @@ -906,6 +906,6 @@ namespace detail { template using FunctionMakeDefaultConstructible = typename detail::DcFuncType::Type; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/initializer_list.hh b/octa/initializer_list.hh index 4e9b8e0..14ee683 100644 --- a/octa/initializer_list.hh +++ b/octa/initializer_list.hh @@ -17,13 +17,13 @@ namespace std { template class initializer_list { const T *p_buf; - octa::Size p_len; + ostd::Size p_len; - constexpr initializer_list(const T *v, octa::Size n): p_buf(v), p_len(n) {} + constexpr initializer_list(const T *v, ostd::Size n): p_buf(v), p_len(n) {} public: constexpr initializer_list(): p_buf(nullptr), p_len(0) {} - constexpr octa::Size size() const { return p_len; } + constexpr ostd::Size size() const { return p_len; } constexpr const T *begin() const { return p_buf; } constexpr const T *end() const { return p_buf + p_len; } @@ -34,7 +34,7 @@ public: #include #endif -namespace octa { +namespace ostd { template using InitializerList = std::initializer_list; diff --git a/octa/internal/hashtable.hh b/octa/internal/hashtable.hh index e14e816..89af7ae 100644 --- a/octa/internal/hashtable.hh +++ b/octa/internal/hashtable.hh @@ -14,7 +14,7 @@ #include "octa/range.hh" #include "octa/initializer_list.hh" -namespace octa { +namespace ostd { namespace detail { template @@ -618,6 +618,6 @@ public: }; } /* namespace detail */ -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/internal/tuple.hh b/octa/internal/tuple.hh index eed9329..bc118a7 100644 --- a/octa/internal/tuple.hh +++ b/octa/internal/tuple.hh @@ -10,7 +10,7 @@ #include "octa/types.hh" #include "octa/type_traits.hh" -namespace octa { +namespace ostd { template class Tuple; template struct Pair; @@ -276,6 +276,6 @@ namespace detail { > {}; } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/io.hh b/octa/io.hh index 334b62e..f28a330 100644 --- a/octa/io.hh +++ b/octa/io.hh @@ -13,7 +13,7 @@ #include "octa/stream.hh" #include "octa/format.hh" -namespace octa { +namespace ostd { enum class StreamMode { read, write, append, @@ -125,8 +125,8 @@ struct FileStream: Stream { } void swap(FileStream &s) { - octa::swap(p_f, s.p_f); - octa::swap(p_owned, s.p_owned); + ostd::swap(p_f, s.p_f); + ostd::swap(p_owned, s.p_owned); } FILE *get_file() { return p_f; } @@ -153,7 +153,7 @@ inline void write(const AnyString &s) { template inline void write(const T &v) { - write(octa::to_string(v)); + write(ostd::to_string(v)); } template @@ -175,7 +175,7 @@ inline void writeln(const AnyString &s) { template inline void writeln(const T &v) { - writeln(octa::to_string(v)); + writeln(ostd::to_string(v)); } template @@ -231,6 +231,6 @@ inline void writefln(const AnyString &fmt, putc('\n', ::stdout); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/map.hh b/octa/map.hh index 67b15e9..c692b56 100644 --- a/octa/map.hh +++ b/octa/map.hh @@ -14,7 +14,7 @@ #include "octa/internal/hashtable.hh" -namespace octa { +namespace ostd { namespace detail { template struct MapBase { @@ -51,7 +51,7 @@ namespace detail { public: using Key = K; using Mapped = T; - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Hasher = H; using KeyEqual = C; @@ -177,6 +177,6 @@ template< typename A = Allocator> > using Multimap = detail::MapImpl; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/maybe.hh b/octa/maybe.hh index e753355..1d8240d 100644 --- a/octa/maybe.hh +++ b/octa/maybe.hh @@ -13,7 +13,7 @@ #include "octa/initializer_list.hh" #include "octa/functional.hh" -namespace octa { +namespace ostd { struct InPlace {}; constexpr InPlace in_place = InPlace(); @@ -254,7 +254,7 @@ public: } Size to_hash() const { - return this->p_engaged ? octa::ToHash()(this->p_value) : 0; + return this->p_engaged ? ostd::ToHash()(this->p_value) : 0; } }; @@ -421,6 +421,6 @@ inline constexpr Maybe> make_maybe(T &&v) { return Maybe>(forward(v)); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/memory.hh b/octa/memory.hh index 79715de..67dc804 100644 --- a/octa/memory.hh +++ b/octa/memory.hh @@ -12,7 +12,7 @@ #include "octa/utility.hh" #include "octa/type_traits.hh" -namespace octa { +namespace ostd { /* address of */ template constexpr T *address_of(T &v) { @@ -529,7 +529,7 @@ template<> struct Allocator { }; template struct Allocator { - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Value = T; using Reference = T &; @@ -566,7 +566,7 @@ template struct Allocator { }; template struct Allocator { - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Value = const T; using Reference = const T &; @@ -1113,6 +1113,6 @@ struct UsesAllocatorConstructor: IntegralConstant::value > {}; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/new.hh b/octa/new.hh index e098497..9a561a5 100644 --- a/octa/new.hh +++ b/octa/new.hh @@ -9,8 +9,8 @@ #ifndef OCTA_ALLOW_CXXSTD #include "octa/types.hh" -inline void *operator new (octa::Size, void *p) { return p; } -inline void *operator new [](octa::Size, void *p) { return p; } +inline void *operator new (ostd::Size, void *p) { return p; } +inline void *operator new [](ostd::Size, void *p) { return p; } inline void operator delete (void *, void *) {} inline void operator delete[](void *, void *) {} #else diff --git a/octa/platform.hh b/octa/platform.hh index dec5355..8c11bbf 100644 --- a/octa/platform.hh +++ b/octa/platform.hh @@ -71,7 +71,7 @@ # endif #endif -namespace octa { +namespace ostd { #if defined(OCTA_TOOLCHAIN_GNU) diff --git a/octa/range.hh b/octa/range.hh index 18b4d82..f9c9ed0 100644 --- a/octa/range.hh +++ b/octa/range.hh @@ -14,7 +14,7 @@ #include "octa/utility.hh" #include "octa/type_traits.hh" -namespace octa { +namespace ostd { struct InputRangeTag {}; struct OutputRangeTag {}; @@ -1182,6 +1182,6 @@ AppenderRange appender(T &&v) { // range of template using RangeOf = decltype(iter(declval())); -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/set.hh b/octa/set.hh index 28c8f55..7a422b1 100644 --- a/octa/set.hh +++ b/octa/set.hh @@ -14,7 +14,7 @@ #include "octa/internal/hashtable.hh" -namespace octa { +namespace ostd { namespace detail { template struct SetBase { @@ -40,7 +40,7 @@ namespace detail { public: using Key = T; - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Hasher = H; using KeyEqual = C; @@ -148,6 +148,6 @@ template< typename A = Allocator > using Multiset = detail::SetImpl; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/stream.hh b/octa/stream.hh index a0631f2..c88fcb1 100644 --- a/octa/stream.hh +++ b/octa/stream.hh @@ -16,7 +16,7 @@ #include "octa/utility.hh" #include "octa/format.hh" -namespace octa { +namespace ostd { #ifndef OCTA_PLATFORM_WIN32 using StreamOffset = off_t; diff --git a/octa/string.hh b/octa/string.hh index e5a052e..8834c5c 100644 --- a/octa/string.hh +++ b/octa/string.hh @@ -13,7 +13,7 @@ #include "octa/range.hh" #include "octa/vector.hh" -namespace octa { +namespace ostd { static constexpr Size npos = -1; template> class StringBase; @@ -144,7 +144,7 @@ template class StringBase { using StrPair = detail::CompressedPair, A>; - octa::Size p_len, p_cap; + ostd::Size p_len, p_cap; StrPair p_buf; template @@ -178,7 +178,7 @@ class StringBase { } public: - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Value = T; using Reference = T &; @@ -587,7 +587,7 @@ template AnyString concat(AllocatorArg, const A &alloc, const T &v, const S &sep, F func) { AnyString ret(alloc); - auto range = octa::iter(v); + auto range = ostd::iter(v); if (range.empty()) return ret; for (;;) { ret += func(range.front()); @@ -602,7 +602,7 @@ template AnyString concat(AllocatorArg, const A &alloc, const T &v, const S &sep = " ") { AnyString ret(alloc); - auto range = octa::iter(v); + auto range = ostd::iter(v); if (range.empty()) return ret; for (;;) { ret += range.front(); @@ -626,23 +626,23 @@ String concat(const T &v, const S &sep = " ") { template AnyString concat(AllocatorArg, const A &alloc, std::initializer_list v, const S &sep, F func) { - return concat(allocator_arg, alloc, octa::iter(v), sep, func); + return concat(allocator_arg, alloc, ostd::iter(v), sep, func); } template AnyString concat(AllocatorArg, const A &alloc, std::initializer_list v, const S &sep = " ") { - return concat(allocator_arg, alloc, octa::iter(v), sep); + return concat(allocator_arg, alloc, ostd::iter(v), sep); } template String concat(std::initializer_list v, const S &sep, F func) { - return concat(octa::iter(v), sep, func); + return concat(ostd::iter(v), sep, func); } template String concat(std::initializer_list v, const S &sep = " ") { - return concat(octa::iter(v), sep); + return concat(ostd::iter(v), sep); } namespace detail { @@ -656,7 +656,7 @@ namespace detail { using ToStringTest = decltype(test_tostring(0)); template - True test_iterable(decltype(octa::iter(declval())) *); + True test_iterable(decltype(ostd::iter(declval())) *); template static False test_iterable(...); template @@ -673,9 +673,9 @@ struct ToString::value>> { String operator()(const T &v) const { String ret("{"); - ret += concat(octa::iter(v), ", ", ToString< + ret += concat(ostd::iter(v), ", ", ToString< RemoveConst + RangeReference >> >()); ret += "}"; @@ -821,6 +821,6 @@ String to_string(std::initializer_list init) { return to_string(iter(init)); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/tuple.hh b/octa/tuple.hh index e313ce0..4a57dc2 100644 --- a/octa/tuple.hh +++ b/octa/tuple.hh @@ -13,7 +13,7 @@ #include "octa/memory.hh" #include "octa/utility.hh" -namespace octa { +namespace ostd { /* tuple size */ @@ -556,6 +556,6 @@ inline bool operator>=(const Tuple &x, const Tuple &y) { template struct UsesAllocator, A>: True {}; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/type_traits.hh b/octa/type_traits.hh index 98f3fa4..3285284 100644 --- a/octa/type_traits.hh +++ b/octa/type_traits.hh @@ -10,7 +10,7 @@ #include "octa/types.hh" -namespace octa { +namespace ostd { /* forward declarations */ namespace detail { @@ -1235,6 +1235,6 @@ namespace detail { template using UnderlyingType = typename detail::UnderlyingTypeBase::Type; -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/types.hh b/octa/types.hh index cfce8a9..058b88c 100644 --- a/octa/types.hh +++ b/octa/types.hh @@ -9,7 +9,7 @@ #include #include -namespace octa { +namespace ostd { /* "builtin" types */ diff --git a/octa/utility.hh b/octa/utility.hh index 48e9dce..fb5bf2f 100644 --- a/octa/utility.hh +++ b/octa/utility.hh @@ -11,7 +11,7 @@ #include "octa/type_traits.hh" #include "octa/internal/tuple.hh" -namespace octa { +namespace ostd { /* move */ @@ -81,7 +81,7 @@ template inline void swap(T (&a)[N], T (&b)[N]) { namespace detail { template inline void swap_adl(T &a, T &b) { - using octa::swap; + using ostd::swap; swap(a, b); } } @@ -382,6 +382,6 @@ namespace detail { }; } /* namespace detail */ -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/octa/vector.hh b/octa/vector.hh index 1d15089..fa5e855 100644 --- a/octa/vector.hh +++ b/octa/vector.hh @@ -16,13 +16,13 @@ #include "octa/initializer_list.hh" #include "octa/memory.hh" -namespace octa { +namespace ostd { template> class Vector { using VecPair = detail::CompressedPair, A>; - octa::Size p_len, p_cap; + ostd::Size p_len, p_cap; VecPair p_buf; void insert_base(Size idx, Size n) { @@ -74,7 +74,7 @@ class Vector { } public: - using Size = octa::Size; + using Size = ostd::Size; using Difference = Ptrdiff; using Value = T; using Reference = T &; @@ -382,7 +382,7 @@ public: } Range insert(Size idx, InitializerList il) { - return insert_range(idx, octa::iter(il)); + return insert_range(idx, ostd::iter(il)); } Range iter() { @@ -450,6 +450,6 @@ inline bool operator>=(const Vector &x, const Vector &y) { return !(x < y); } -} /* namespace octa */ +} /* namespace ostd */ #endif \ No newline at end of file diff --git a/src/new.cc b/src/new.cc index e5c5444..b8c71ef 100644 --- a/src/new.cc +++ b/src/new.cc @@ -7,13 +7,13 @@ #include "octa/types.hh" -void *operator new(octa::Size size) { +void *operator new(ostd::Size size) { void *p = malloc(size); if (!p) abort(); return p; } -void *operator new[](octa::Size size) { +void *operator new[](ostd::Size size) { void *p = malloc(size); if (!p) abort(); return p; diff --git a/tests/array.cc b/tests/array.cc index 66b4619..b807b73 100644 --- a/tests/array.cc +++ b/tests/array.cc @@ -3,7 +3,7 @@ #include "octa/array.hh" #include "octa/string.hh" -using namespace octa; +using namespace ostd; int main() { Array x = { 2, 4, 8, 16, 32 }; diff --git a/tests/utility.cc b/tests/utility.cc index d93db16..3d1e302 100644 --- a/tests/utility.cc +++ b/tests/utility.cc @@ -3,7 +3,7 @@ #include "octa/utility.hh" #include "octa/string.hh" -using namespace octa; +using namespace ostd; struct Foo { int x; diff --git a/tests/vector.cc b/tests/vector.cc index 8a7c8d6..59ff146 100644 --- a/tests/vector.cc +++ b/tests/vector.cc @@ -3,7 +3,7 @@ #include "octa/vector.hh" #include "octa/string.hh" -using namespace octa; +using namespace ostd; int main() { Vector x = { 5, 10, 15, 20 };