std allowed by default

master
Daniel Kolesa 2017-01-14 15:09:27 +01:00
parent 32cd56d3c1
commit 41ad273c32
12 changed files with 31 additions and 138 deletions

View File

@ -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++.

View File

@ -8,9 +8,9 @@
#define OSTD_FUNCTIONAL_HH
#include <string.h>
#include <new>
#include "ostd/platform.hh"
#include "ostd/new.hh"
#include "ostd/memory.hh"
#include "ostd/utility.hh"
#include "ostd/type_traits.hh"

View File

@ -6,41 +6,12 @@
#ifndef OSTD_INITIALIZER_LIST_HH
#define OSTD_INITIALIZER_LIST_HH
#include <stddef.h>
#include <initializer_list>
#include "ostd/range.hh"
#ifndef OSTD_ALLOW_CXXSTD
/* must be in std namespace otherwise the compiler won't know about it */
namespace std {
template<typename T>
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 <initializer_list>
#endif
namespace ostd {
template<typename T>
using InitializerList = std::initializer_list<T>;
template<typename T>
PointerRange<T const> iter(std::initializer_list<T> init) noexcept {
return PointerRange<T const>(init.begin(), init.end());

View File

@ -366,7 +366,7 @@ protected:
rehash_up();
}
void assign_init(InitializerList<E> il) {
void assign_init(std::initializer_list<E> il) {
const E *beg = il.begin(), *end = il.end();
clear();
reserve_at_least(end - beg);

View File

@ -116,18 +116,18 @@ namespace detail {
{}
KeysetImpl(
InitializerList<Value> init, Size size = 0,
std::initializer_list<Value> 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<Value> init, Size size, A const &alloc):
KeysetImpl(std::initializer_list<Value> init, Size size, A const &alloc):
KeysetImpl(iter(init), size, H(), C(), alloc)
{}
KeysetImpl(
InitializerList<Value> init, Size size, H const &hf, A const &alloc
std::initializer_list<Value> 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<Value> il) {
KeysetImpl &operator=(std::initializer_list<Value> il) {
Base::assign_init(il);
return *this;
}

View File

@ -118,18 +118,18 @@ namespace detail {
{}
MapImpl(
InitializerList<Value> init, Size size = 0,
std::initializer_list<Value> 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<Value> init, Size size, A const &alloc):
MapImpl(std::initializer_list<Value> init, Size size, A const &alloc):
MapImpl(iter(init), size, H(), C(), alloc)
{}
MapImpl(
InitializerList<Value> init, Size size, H const &hf, A const &alloc
std::initializer_list<Value> 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<Value> il) {
MapImpl &operator=(std::initializer_list<Value> il) {
Base::assign_init(il);
return *this;
}

View File

@ -7,8 +7,8 @@
#define OSTD_MEMORY_HH
#include <stddef.h>
#include <new>
#include "ostd/new.hh"
#include "ostd/utility.hh"
#include "ostd/type_traits.hh"

View File

@ -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 <new>
#endif
#endif

View File

@ -8,8 +8,8 @@
#include <stddef.h>
#include <string.h>
#include <new>
#include "ostd/new.hh"
#include "ostd/types.hh"
#include "ostd/utility.hh"
#include "ostd/type_traits.hh"

View File

@ -107,18 +107,18 @@ namespace detail {
{}
SetImpl(
InitializerList<Value> init, Size size = 0,
std::initializer_list<Value> 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<Value> init, Size size, A const &alloc):
SetImpl(std::initializer_list<Value> init, Size size, A const &alloc):
SetImpl(iter(init), size, H(), C(), alloc)
{}
SetImpl(
InitializerList<Value> init, Size size, H const &hf, A const &alloc
std::initializer_list<Value> 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<Value> il) {
SetImpl &operator=(std::initializer_list<Value> il) {
Base::assign_init(il);
return *this;
}

View File

@ -163,7 +163,7 @@ public:
p_len = r.size();
}
Vector(InitializerList<T> v, A const &a = A()):
Vector(std::initializer_list<T> v, A const &a = A()):
Vector(ConstRange(v.begin(), v.size()), a)
{}
@ -222,7 +222,7 @@ public:
return *this;
}
Vector &operator=(InitializerList<T> il) {
Vector &operator=(std::initializer_list<T> 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<T> il) {
Range insert(Size idx, std::initializer_list<T> il) {
return insert_range(idx, ostd::iter(il));
}

View File

@ -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 <stdlib.h>
#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);
}