forked from OctaForge/libostd
bump compiler
This commit is contained in:
parent
58a361e6e0
commit
632147c5fb
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
|||
OSTD_CXXFLAGS = -O2 -g -std=c++14 -Wall -Wextra -Wshadow -Wold-style-cast -I.
|
||||
OSTD_CXXFLAGS = -O2 -g -std=c++1z -Wall -Wextra -Wshadow -Wold-style-cast -I.
|
||||
|
||||
EXAMPLES_OBJ = \
|
||||
examples/format \
|
||||
|
|
47
README.md
47
README.md
|
@ -1,6 +1,6 @@
|
|||
# octastd
|
||||
|
||||
OctaSTD is an extension of the C++14 standard library which mainly provides
|
||||
OctaSTD is an extension of the C++17 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
|
||||
|
@ -8,42 +8,45 @@ make the language easier and more convenient to use.
|
|||
|
||||
Documentation for OctaSTD can be found at https://wiki.octaforge.org/docs/octastd.
|
||||
|
||||
Full C++14 support is required in your compiler.
|
||||
It's not necessary that your compiler fully supports C++17, only C++14
|
||||
language is used, but new C++17 containers have to be present, such as
|
||||
`string_view` and `optional`.
|
||||
|
||||
## Supported compilers
|
||||
|
||||
Compiler | Version
|
||||
-------- | -------
|
||||
gcc/g++ | 5.4+, 6+
|
||||
clang | 3.8+ (most platforms including LLVM for macOS), 8.0.0+ (macOS Xcode)
|
||||
gcc/g++ | 7+
|
||||
clang | 4+
|
||||
|
||||
Other C++14 compliant compilers might work as well. OctaSTD does not utilize
|
||||
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
|
||||
functioning. Therefore version 3.8 or higher is necessary (where this bug was
|
||||
finally fixed).
|
||||
|
||||
GCC has implemented a sufficient feature level of C++14 since version 5.1, but
|
||||
also is too buggy until version 5.4. Version 5.1 and 5.2 have variable template
|
||||
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.
|
||||
You need those mainly to get the right standard library version (libstdc++
|
||||
or libc++). Other compilers might work as well, as long as the necessary
|
||||
standard library features are supplied.
|
||||
|
||||
MSVC++ is unsupported and for the time being will remain unsupported. As of MS
|
||||
Visual Studio 2017 RC, basic C++11 features are still broken and prevent usage
|
||||
of the library, with no reasonable workarounds. I will be testing new versions
|
||||
as they get released and mark it supported as soon as it actually works, but no
|
||||
active effort will be put towards making it work. On Windows, you're free to
|
||||
use GCC/Clang or if you need the Visual Studio environment, the Visual Studio
|
||||
version of Clang with MS Codegen should work just fine.
|
||||
use GCC/Clang, if you need Visual Studio, LLVM integration exists.
|
||||
|
||||
## Why is C++17 necessary?
|
||||
|
||||
Sadly, it's not possible to properly integrate `std::string` and `std::hash`
|
||||
with OctaSTD ranges without utilizing `std::string_view`. Also, C++17 provides
|
||||
library features that OctaSTD would have to implement otherwise, which would
|
||||
lead to potentially incompatible APIs. However, OctaSTD does not make wide
|
||||
use of C++17 language features, limiting itself mostly to library features
|
||||
which have been present for more or less a pretty long time (in experimental
|
||||
namespace for example) which should avoid buggy behavior. There is still the
|
||||
problem of requiring a very recent toolchain, but this situation should solve
|
||||
itself in near future.
|
||||
|
||||
## Supported operating systems
|
||||
|
||||
Most of OctaSTD is entirely platform independent and relies only on the standard
|
||||
library. Therefore it can be used on any operating system that provides a C++14
|
||||
compiler and library implementation.
|
||||
Most of OctaSTD is entirely platform independent and relies only on the
|
||||
standard library. Therefore it can be used on any operating system that
|
||||
provides the right toolchain.
|
||||
|
||||
There are certain parts (currently the filesystem module) that however do rely
|
||||
on system specific APIs. These are restricted to POSIX compliant operating
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ostd/utility.hh"
|
||||
#include "ostd/range.hh"
|
||||
#include "ostd/vector.hh"
|
||||
|
@ -208,6 +211,11 @@ diffsize:
|
|||
return c;
|
||||
}
|
||||
|
||||
/* that way we can assign, append etc to std::string */
|
||||
operator std::basic_string_view<RemoveCv<T>>() const {
|
||||
return std::basic_string_view<RemoveCv<T>>{data(), size()};
|
||||
}
|
||||
|
||||
private:
|
||||
T *p_beg, *p_end;
|
||||
};
|
||||
|
@ -246,6 +254,20 @@ inline bool starts_with(ConstCharRange a, ConstCharRange b) {
|
|||
return a.slice(0, b.size()) == b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct ranged_traits<std::basic_string<T>> {
|
||||
static CharRangeBase<T> iter(std::basic_string<T> &v) {
|
||||
return CharRangeBase<T>{v.data(), v.size()};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ranged_traits<std::basic_string<T> const> {
|
||||
static CharRangeBase<T const> iter(std::basic_string<T> const &v) {
|
||||
return CharRangeBase<T const>{v.data(), v.size()};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename A>
|
||||
class StringBase {
|
||||
using StrPair = detail::CompressedPair<AllocatorPointer<A>, A>;
|
||||
|
@ -951,6 +973,15 @@ struct ToString<String> {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ToString<std::string> {
|
||||
using Argument = std::string;
|
||||
using Result = String;
|
||||
String operator()(Argument const &s) {
|
||||
return iter(s);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ToString<CharRange> {
|
||||
using Argument = CharRange;
|
||||
|
@ -1124,4 +1155,22 @@ inline TempCString<R> to_temp_cstr(
|
|||
|
||||
} /* namespace ostd */
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<ostd::CharRange> {
|
||||
size_t operator()(ostd::CharRange const &v) {
|
||||
return hash<std::string_view>{}(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<ostd::ConstCharRange> {
|
||||
size_t operator()(ostd::CharRange const &v) {
|
||||
return hash<std::string_view>{}(v);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,7 @@ int main() {
|
|||
/* configurable section */
|
||||
|
||||
auto compiler = env_get("CXX").value_or("c++");
|
||||
auto cxxflags = "-std=c++14 -I. -Wall -Wextra -Wshadow -Wold-style-cast "
|
||||
auto cxxflags = "-std=c++1z -I. -Wall -Wextra -Wshadow -Wold-style-cast "
|
||||
"-Wno-missing-braces"; /* clang false positive */
|
||||
auto testdir = env_get("TESTDIR").value_or("tests");
|
||||
auto srcext = ".cc";
|
||||
|
|
Loading…
Reference in a new issue