With future C++ standards, library will switch to std::optional, however
for now we need a wrapper to choose between our bundled implementation,
std::experimental::optional (if that's available) and std::optional
(when that's available)
Style changes:
* Change namespace: std::experimental -> SDL2pp::cpp_optional
* Change _LIBCPP_BEGIN_NAMESPACE_STD to plain "namespace std {"
* Remove _LIBCPP_INLINE_VISIBILITY, _LIBCPP_EXCEPTION_ABI
* Change _NOEXEPT to noexcept
* Address all c++ standard library primitives via std::
Functional changes:
* Change _LIBCPP_ASSERT() to plain assert()
* Remove constexpr from functions which require c++1y relaxed constexpr
requirements
* Change __is_nothrow_swappable condition for noexcept of swap(), to
noexcept(std::swap) (idea taken from libstdc++)
* Remove constexpr from operator-> const to not require
internal __has_operator_addressof
Streams do not generally work well with RWops because
* streams have separate read and write pointers
* ostream doesn't allow you to determine how many bytes were actually written
* istream and ostream have separate set of functions
Try my best to support streams in RWops though, engaging some template
magic:
* provide separate template implementations of all operations which
depend on whether stream is an istream or ostream. This allows to
e.g. return 0 immediately for an attempt to write() to istream.
* disallow StreamRWops for classes which are both istream and ostream
to not run into ambiguity of separate read/write pointers
* for read failure, but partially read object back to the stream to not
lose data for following read (not sure that e.g. fread behaves so
though; I'll anyway expect user to Seek() after read or write failure)
* for write failure, there's no way to avoid leaking partial data to the
stream
In general, it is best to use this container as read-only.
Also add tests for StreamRWops
Though this is not 100% compatible with SDL2, this makes API much
more consistent and less error prone. For example, you don't need
to store AudioSpec along with AudioDevice just to have your callback
lambda around, you don't need to copy AudioSpec from Wav file just
to fill in the callback (see wav demo), you are no more obliged to
take care of locking AudioDevice while replacing the callback.
std::function(std::function&&) is only noexcept in libc++, not
libstdc++, so calculated signatire of move ctor/assignment of AudioSpec
won't match specification