diff --git a/README.md b/README.md index d01c530..604df1e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # octastd -OctaSTD is a new "standard library" for C++14. It provides containers -(dynamic arrays etc) as well as other utilities. +OctaSTD is an extension of the C++14 standard library which mainly provides +ranges (to replace iterators) but also various other utilities like proper +streams, string formatting, concurrency utilities and others. It's meant +to replace the more poorly designed parts of the C++ standard library to +make the language easier and more convenient to use. Documentation for OctaSTD can be found at https://wiki.octaforge.org/docs/octastd. @@ -15,12 +18,7 @@ gcc/g++ | 5.4+, 6+ clang | 3.8+ (most platforms including LLVM for macOS), 8.0.0+ (macOS Xcode) Other C++14 compliant compilers might work as well. OctaSTD does not utilize -compiler specific extensions except certain builtin type traits - to implement -traits that are not normally possible to implement without compiler support. - -OctaSTD does not provide fallbacks for those traits. The compiler is expected -to support these builtins. So far the 2 above-mentioned compilers support them -(MSVC++ supports most of these as well). +compiler specific extensions. While Clang 3.6 does implement a sufficient level of C++14 support, it suffers from a bug in its variable template implementation that prevents OctaSTD from @@ -33,45 +31,17 @@ partial specialization issues and version 5.3 has an internal compiler error triggered by the tuple implementation. Version 5.4 appears to be the first one to compile this without issues. GCC 6.1 also appears to compile without problems. -MSVC++ is currently unsupported. Support is currently being investigated and -might be added at least for VS 2015 Update 2, assuming I don't run into any -significant bugs or missing features. MSVC++ with Clang frontend will be -supported once Microsoft updates it to Clang 3.8 (3.7 as is currently shipped -suffers from the issue mentioned above). +MSVC++ is currently unsupported but being worked on. You will need at least +2015 Update 3 for this to work. ## Supported operating systems -Currently supported OSes in OctaSTD are Linux, FreeBSD and macOS. Other -systems that implement POSIX API will also work (if they don't, bug reports -are welcome). +Currently supported OSes in OctaSTD are Linux, FreeBSD, macOS and Windows. Other +systems might work as well, as long as a sufficient compiler is provided. MacOS support requires Xcode 8 or newer to work (or alternatively, official LLVM distribution for macOS or any supported compiler from other channels such as Homebrew). That is the first version to ship a Clang 3.8 based toolchain, so things will not compile with an older version of Xcode. -Windows is supported with GCC (MinGW) and Clang. The MS C runtime is supported -as well, so compiling with Clang targeting MSVC compatibility will work. - -## Exceptions - -The library is written with the idea that no API in it ever throws exceptions (with -possibly some rare... exceptions ;)). However, this does not mean it cannot be used -in code that utilizes exceptions. Because of this, the library attempts to provide -some degree of exception safety as well as proper `noexcept` annotations. It also -provides type traits to check things such as whether something can be constructed -or assigned to without throwing. - -This is currently a work in progress though. Here is a list of files where things -have been correctly annotated: - -* array.hh -* initializer_list.hh -* memory.hh -* new.hh -* platform.hh -* utility.hh -* type_traits.hh - -This list will expand over time. As for exception safety of containers, it's is -currently not done/checked. They will be made exception safe over time too. +Windows support includes MinGW, Clang and soon MSVC++. \ No newline at end of file diff --git a/ostd/functional.hh b/ostd/functional.hh index 2f58dad..c6021ee 100644 --- a/ostd/functional.hh +++ b/ostd/functional.hh @@ -8,9 +8,9 @@ #define OSTD_FUNCTIONAL_HH #include +#include #include "ostd/platform.hh" -#include "ostd/new.hh" #include "ostd/memory.hh" #include "ostd/utility.hh" #include "ostd/type_traits.hh" diff --git a/ostd/initializer_list.hh b/ostd/initializer_list.hh index 709dcb5..fa0a0dd 100644 --- a/ostd/initializer_list.hh +++ b/ostd/initializer_list.hh @@ -6,41 +6,12 @@ #ifndef OSTD_INITIALIZER_LIST_HH #define OSTD_INITIALIZER_LIST_HH -#include +#include #include "ostd/range.hh" -#ifndef OSTD_ALLOW_CXXSTD -/* must be in std namespace otherwise the compiler won't know about it */ -namespace std { - -template -class initializer_list { - T const *p_buf; - ostd::Size p_len; - - constexpr initializer_list(T const *v, ostd::Size n) noexcept: - p_buf(v), p_len(n) - {} -public: - constexpr initializer_list() noexcept: p_buf(nullptr), p_len(0) {} - - constexpr ostd::Size size() const noexcept { return p_len; } - - constexpr T const *begin() const noexcept { return p_buf; } - constexpr T const *end() const noexcept { return p_buf + p_len; } -}; - -} -#else -#include -#endif - namespace ostd { -template -using InitializerList = std::initializer_list; - template PointerRange iter(std::initializer_list init) noexcept { return PointerRange(init.begin(), init.end()); diff --git a/ostd/internal/hashtable.hh b/ostd/internal/hashtable.hh index 4f9d21c..9587c46 100644 --- a/ostd/internal/hashtable.hh +++ b/ostd/internal/hashtable.hh @@ -366,7 +366,7 @@ protected: rehash_up(); } - void assign_init(InitializerList il) { + void assign_init(std::initializer_list il) { const E *beg = il.begin(), *end = il.end(); clear(); reserve_at_least(end - beg); diff --git a/ostd/keyset.hh b/ostd/keyset.hh index e7e2404..95d9eb0 100644 --- a/ostd/keyset.hh +++ b/ostd/keyset.hh @@ -116,18 +116,18 @@ namespace detail { {} KeysetImpl( - InitializerList init, Size size = 0, + std::initializer_list init, Size size = 0, H const &hf = H(), C const &eqf = C(), A const &alloc = A() ): KeysetImpl(iter(init), size, hf, eqf, alloc) {} - KeysetImpl(InitializerList init, Size size, A const &alloc): + KeysetImpl(std::initializer_list init, Size size, A const &alloc): KeysetImpl(iter(init), size, H(), C(), alloc) {} KeysetImpl( - InitializerList init, Size size, H const &hf, A const &alloc + std::initializer_list init, Size size, H const &hf, A const &alloc ): KeysetImpl(iter(init), size, hf, C(), alloc) {} @@ -150,7 +150,7 @@ namespace detail { return *this; } - KeysetImpl &operator=(InitializerList il) { + KeysetImpl &operator=(std::initializer_list il) { Base::assign_init(il); return *this; } diff --git a/ostd/map.hh b/ostd/map.hh index 131c353..2ee17d5 100644 --- a/ostd/map.hh +++ b/ostd/map.hh @@ -118,18 +118,18 @@ namespace detail { {} MapImpl( - InitializerList init, Size size = 0, + std::initializer_list init, Size size = 0, H const &hf = H(), C const &eqf = C(), A const &alloc = A() ): MapImpl(iter(init), size, hf, eqf, alloc) {} - MapImpl(InitializerList init, Size size, A const &alloc): + MapImpl(std::initializer_list init, Size size, A const &alloc): MapImpl(iter(init), size, H(), C(), alloc) {} MapImpl( - InitializerList init, Size size, H const &hf, A const &alloc + std::initializer_list init, Size size, H const &hf, A const &alloc ): MapImpl(iter(init), size, hf, C(), alloc) {} @@ -152,7 +152,7 @@ namespace detail { return *this; } - MapImpl &operator=(InitializerList il) { + MapImpl &operator=(std::initializer_list il) { Base::assign_init(il); return *this; } diff --git a/ostd/memory.hh b/ostd/memory.hh index 40d1034..dd3d28e 100644 --- a/ostd/memory.hh +++ b/ostd/memory.hh @@ -7,8 +7,8 @@ #define OSTD_MEMORY_HH #include +#include -#include "ostd/new.hh" #include "ostd/utility.hh" #include "ostd/type_traits.hh" diff --git a/ostd/new.hh b/ostd/new.hh deleted file mode 100644 index a183ce8..0000000 --- a/ostd/new.hh +++ /dev/null @@ -1,20 +0,0 @@ -/* Default new/delete operator overloads for OctaSTD. Also has an impl file. - * - * This file is part of OctaSTD. See COPYING.md for futher information. - */ - -#ifndef OSTD_NEW_HH -#define OSTD_NEW_HH - -#ifndef OSTD_ALLOW_CXXSTD -#include "ostd/types.hh" - -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 *) noexcept {} -inline void operator delete[](void *, void *) noexcept {} -#else -#include -#endif - -#endif diff --git a/ostd/range.hh b/ostd/range.hh index d1fa64c..2d0710b 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -8,8 +8,8 @@ #include #include +#include -#include "ostd/new.hh" #include "ostd/types.hh" #include "ostd/utility.hh" #include "ostd/type_traits.hh" diff --git a/ostd/set.hh b/ostd/set.hh index b91b074..21dc160 100644 --- a/ostd/set.hh +++ b/ostd/set.hh @@ -107,18 +107,18 @@ namespace detail { {} SetImpl( - InitializerList init, Size size = 0, + std::initializer_list init, Size size = 0, H const &hf = H(), C const &eqf = C(), A const &alloc = A() ): SetImpl(iter(init), size, hf, eqf, alloc) {} - SetImpl(InitializerList init, Size size, A const &alloc): + SetImpl(std::initializer_list init, Size size, A const &alloc): SetImpl(iter(init), size, H(), C(), alloc) {} SetImpl( - InitializerList init, Size size, H const &hf, A const &alloc + std::initializer_list init, Size size, H const &hf, A const &alloc ): SetImpl(iter(init), size, hf, C(), alloc) {} @@ -141,7 +141,7 @@ namespace detail { return *this; } - SetImpl &operator=(InitializerList il) { + SetImpl &operator=(std::initializer_list il) { Base::assign_init(il); return *this; } diff --git a/ostd/vector.hh b/ostd/vector.hh index 3678ddb..b0e8340 100644 --- a/ostd/vector.hh +++ b/ostd/vector.hh @@ -163,7 +163,7 @@ public: p_len = r.size(); } - Vector(InitializerList v, A const &a = A()): + Vector(std::initializer_list v, A const &a = A()): Vector(ConstRange(v.begin(), v.size()), a) {} @@ -222,7 +222,7 @@ public: return *this; } - Vector &operator=(InitializerList il) { + Vector &operator=(std::initializer_list il) { clear(); Size ilen = il.end() - il.begin(); reserve(ilen); @@ -436,7 +436,7 @@ public: return Range(&p_buf.first()[idx], &p_buf.first()[p_len]); } - Range insert(Size idx, InitializerList il) { + Range insert(Size idx, std::initializer_list il) { return insert_range(idx, ostd::iter(il)); } diff --git a/src/new.cc b/src/new.cc deleted file mode 100644 index 8080f31..0000000 --- a/src/new.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* Default new/delete operator overloads for OctaSTD. Also has a header file. - * - * This file is part of OctaSTD. See COPYING.md for futher information. - */ - -#include - -#include "ostd/types.hh" - -void *operator new(ostd::Size size) { - void *p = malloc(size); - if (!p) abort(); - return p; -} - -void *operator new[](ostd::Size size) { - void *p = malloc(size); - if (!p) abort(); - return p; -} - -void operator delete(void *p) noexcept { - free(p); -} - -void operator delete[](void *p) noexcept { - free(p); -}