mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
temporary workaround for old GCC
This commit is contained in:
parent
8274f34db4
commit
6e8f686f72
6 changed files with 101 additions and 20 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
|
#include <sprout/algorithm/cxx14/swap_ranges.hpp>
|
||||||
#include <sprout/utility/forward.hpp>
|
#include <sprout/utility/forward.hpp>
|
||||||
#include <sprout/utility/swap.hpp>
|
#include <sprout/utility/swap.hpp>
|
||||||
|
#include <sprout/utility/string_view/string_view_fwd.hpp>
|
||||||
#include <sprout/type_traits/integral_constant.hpp>
|
#include <sprout/type_traits/integral_constant.hpp>
|
||||||
#include <sprout/type_traits/identity.hpp>
|
#include <sprout/type_traits/identity.hpp>
|
||||||
#include <sprout/type_traits/enabler_if.hpp>
|
#include <sprout/type_traits/enabler_if.hpp>
|
||||||
|
@ -885,6 +886,9 @@ namespace sprout {
|
||||||
SPROUT_EXPLICIT_CONVERSION SPROUT_NON_CONSTEXPR operator std::basic_string<T, Traits, Allocator>() const {
|
SPROUT_EXPLICIT_CONVERSION SPROUT_NON_CONSTEXPR operator std::basic_string<T, Traits, Allocator>() const {
|
||||||
return std::basic_string<T, Traits, Allocator>(data(), size());
|
return std::basic_string<T, Traits, Allocator>(data(), size());
|
||||||
}
|
}
|
||||||
|
operator sprout::basic_string_view<T, Traits>() const SPROUT_NOEXCEPT {
|
||||||
|
return sprout::basic_string_view<T, Traits>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
SPROUT_CXX14_CONSTEXPR void rangecheck(size_type i) const {
|
SPROUT_CXX14_CONSTEXPR void rangecheck(size_type i) const {
|
||||||
return i >= size() ? throw std::out_of_range("basic_string<>: index out of range")
|
return i >= size() ? throw std::out_of_range("basic_string<>: index out of range")
|
||||||
|
|
|
@ -137,6 +137,12 @@ namespace sprout {
|
||||||
return sprout::sub_window(arr, to_first);
|
return sprout::sub_window(arr, to_first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container&> >::type
|
||||||
|
sub(Container& arr) {
|
||||||
|
return sprout::sub(arr, sprout::begin(arr), sprout::end(arr));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// csub
|
// csub
|
||||||
//
|
//
|
||||||
|
@ -218,6 +224,12 @@ namespace sprout {
|
||||||
return sprout::csub_window(arr, to_first);
|
return sprout::csub_window(arr, to_first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container const&> >::type
|
||||||
|
csub(Container const& arr) {
|
||||||
|
return sprout::csub(arr, sprout::begin(arr), sprout::end(arr));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// sub_copy
|
// sub_copy
|
||||||
//
|
//
|
||||||
|
@ -298,6 +310,12 @@ namespace sprout {
|
||||||
{
|
{
|
||||||
return sprout::sub_window_copy(arr, to_first);
|
return sprout::sub_window_copy(arr, to_first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Container>
|
||||||
|
inline SPROUT_CONSTEXPR typename std::enable_if<!sprout::is_sub_array<Container>::value, sprout::sub_array<Container> >::type
|
||||||
|
sub_copy(Container const& arr) {
|
||||||
|
return sprout::sub_copy(arr, sprout::begin(arr), sprout::end(arr));
|
||||||
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_SUB_ARRAY_SUB_HPP
|
#endif // #ifndef SPROUT_SUB_ARRAY_SUB_HPP
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <sprout/iterator/reverse_iterator.hpp>
|
#include <sprout/iterator/reverse_iterator.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/utility/swap.hpp>
|
#include <sprout/utility/swap.hpp>
|
||||||
#include <sprout/string/char_traits.hpp>
|
#include <sprout/utility/string_view/string_view_fwd.hpp>
|
||||||
#include <sprout/string/npos.hpp>
|
#include <sprout/string/npos.hpp>
|
||||||
#include <sprout/string/string.hpp>
|
#include <sprout/string/string.hpp>
|
||||||
#include <sprout/string/detail/operations.hpp>
|
#include <sprout/string/detail/operations.hpp>
|
||||||
|
@ -31,7 +31,7 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// basic_string_view
|
// basic_string_view
|
||||||
//
|
//
|
||||||
template<typename T, typename Traits = sprout::char_traits<T> >
|
template<typename T, typename Traits>
|
||||||
class basic_string_view {
|
class basic_string_view {
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
@ -94,14 +94,14 @@ namespace sprout {
|
||||||
: ptr_(str), len_(traits_type::length(str))
|
: ptr_(str), len_(traits_type::length(str))
|
||||||
{}
|
{}
|
||||||
template<std::size_t N>
|
template<std::size_t N>
|
||||||
SPROUT_CONSTEXPR basic_string_view(sprout::basic_string<T, N, Traits> const& str)
|
SPROUT_CONSTEXPR basic_string_view(sprout::basic_string<T, N, Traits> const& str) SPROUT_NOEXCEPT
|
||||||
: ptr_(str.data()), len_(str.size())
|
: ptr_(str.data()), len_(str.size())
|
||||||
{}
|
{}
|
||||||
template<typename Allocator>
|
template<typename Allocator>
|
||||||
SPROUT_NON_CONSTEXPR basic_string_view(std::basic_string<T, Traits, Allocator> const& str)
|
SPROUT_NON_CONSTEXPR basic_string_view(std::basic_string<T, Traits, Allocator> const& str) SPROUT_NOEXCEPT
|
||||||
: ptr_(str.data()), len_(str.size())
|
: ptr_(str.data()), len_(str.size())
|
||||||
{}
|
{}
|
||||||
SPROUT_CONSTEXPR basic_string_view(const_pointer str, size_type len)
|
SPROUT_CONSTEXPR basic_string_view(const_pointer str, size_type len) SPROUT_NOEXCEPT
|
||||||
: ptr_(str), len_(len)
|
: ptr_(str), len_(len)
|
||||||
{}
|
{}
|
||||||
// iterators:
|
// iterators:
|
||||||
|
|
22
sprout/utility/string_view/string_view_fwd.hpp
Normal file
22
sprout/utility/string_view/string_view_fwd.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2011-2017 Bolero MURAKAMI
|
||||||
|
https://github.com/bolero-MURAKAMI/Sprout
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
=============================================================================*/
|
||||||
|
#ifndef SPROUT_UTILITY_STRING_VIEW_STRING_VIEW_FWD_HPP
|
||||||
|
#define SPROUT_UTILITY_STRING_VIEW_STRING_VIEW_FWD_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/string/char_traits.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
//
|
||||||
|
// basic_string_view
|
||||||
|
//
|
||||||
|
template<typename T, typename Traits = sprout::char_traits<T> >
|
||||||
|
class basic_string_view;
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_UTILITY_STRING_VIEW_STRING_VIEW_FWD_HPP
|
|
@ -118,9 +118,11 @@ namespace sprout {
|
||||||
return sprout::addressof(p);
|
return sprout::addressof(p);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR reference ref(holder_type r) {
|
static SPROUT_CONSTEXPR reference ref(holder_type r) {
|
||||||
return r ? *r
|
return *r;
|
||||||
: (throw sprout::bad_optional_access("value_holder<>: bad optional access"), *r)
|
// !!!
|
||||||
;
|
// return r ? *r
|
||||||
|
// : (throw sprout::bad_optional_access("value_holder<>: bad optional access"), *r)
|
||||||
|
// ;
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR pointer ptr(holder_type r) SPROUT_NOEXCEPT {
|
static SPROUT_CONSTEXPR pointer ptr(holder_type r) SPROUT_NOEXCEPT {
|
||||||
return r;
|
return r;
|
||||||
|
@ -148,9 +150,11 @@ namespace sprout {
|
||||||
return sprout::addressof(p);
|
return sprout::addressof(p);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR reference ref(holder_type r) {
|
static SPROUT_CONSTEXPR reference ref(holder_type r) {
|
||||||
return r ? *r
|
return *r;
|
||||||
: (throw sprout::bad_optional_access("value_holder<>: bad optional access"), *r)
|
// !!!
|
||||||
;
|
// return r ? *r
|
||||||
|
// : (throw sprout::bad_optional_access("value_holder<>: bad optional access"), *r)
|
||||||
|
// ;
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR pointer ptr(holder_type r) SPROUT_NOEXCEPT {
|
static SPROUT_CONSTEXPR pointer ptr(holder_type r) SPROUT_NOEXCEPT {
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
@ -58,6 +59,11 @@ namespace testspr {
|
||||||
return what_;
|
return what_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
template<typename Elem, typename Traits>
|
||||||
|
inline SPROUT_NON_CONSTEXPR std::basic_ostream<Elem, Traits>&
|
||||||
|
operator<<(std::basic_ostream<Elem, Traits>& lhs, testspr::trace_info const& rhs) {
|
||||||
|
return lhs << rhs.file() << ':' << rhs.line() << ": " << rhs.tag() << ": " << rhs.what();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// trace_record
|
// trace_record
|
||||||
|
@ -123,9 +129,26 @@ namespace testspr {
|
||||||
std::copy(begin(), end(), out);
|
std::copy(begin(), end(), out);
|
||||||
}
|
}
|
||||||
SPROUT_NON_CONSTEXPR void print() const {
|
SPROUT_NON_CONSTEXPR void print() const {
|
||||||
testspr::print_ln("trace-record current: size:", size(), ":");
|
testspr::print_ln("trace-record current: size:", size(), ':');
|
||||||
for (const_iterator it = cbegin(), last = cend(); it != last; ++it) {
|
for (const_iterator it = cbegin(), last = cend(); it != last; ++it) {
|
||||||
testspr::print_ln(" ", it->first, " - ", it->second.file(), ":", it->second.line(), ": ", it->second.tag(), ": ", it->second.what());
|
testspr::print_ln(" ", it->first, " - ", it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPROUT_NON_CONSTEXPR void print_stratified() const {
|
||||||
|
testspr::print_ln("trace-record current: size:", size(), ':');
|
||||||
|
std::string indent;
|
||||||
|
for (const_iterator it = cbegin(), last = cend(); it != last; ++it) {
|
||||||
|
if (it->first == "push") {
|
||||||
|
testspr::print_ln(" ", indent, it->second, " {");
|
||||||
|
indent.append(2, ' ');
|
||||||
|
} else if (it->first == "pop") {
|
||||||
|
indent.erase(indent.size() - 2);
|
||||||
|
testspr::print_ln(" ", indent, '}');
|
||||||
|
} else if (it->first == "notify") {
|
||||||
|
testspr::print_ln(" ", indent, it->second);
|
||||||
|
} else {
|
||||||
|
testspr::print_ln(" ", indent, it->first, " - ", it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -175,16 +198,14 @@ namespace testspr {
|
||||||
class print_on_push {
|
class print_on_push {
|
||||||
public:
|
public:
|
||||||
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
||||||
testspr::trace_info const& info = stack.top();
|
testspr::print_ln("trace-stack push: ", stack.top());
|
||||||
testspr::print_ln("trace-stack push: ", info.file(), ":", info.line(), ": ", info.tag(), ": ", info.what());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class print_on_pop {
|
class print_on_pop {
|
||||||
public:
|
public:
|
||||||
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
||||||
testspr::trace_info const& info = stack.top();
|
testspr::print_ln("trace-stack pop: ", stack.top());
|
||||||
testspr::print_ln("trace-stack pop: ", info.file(), ":", info.line(), ": ", info.tag(), ": ", info.what());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -206,7 +227,7 @@ namespace testspr {
|
||||||
public:
|
public:
|
||||||
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
SPROUT_NON_CONSTEXPR bool operator()(testspr::trace_stack const& stack) const {
|
||||||
testspr::trace_info const& info = stack.top();
|
testspr::trace_info const& info = stack.top();
|
||||||
testspr::print_ln("trace-stack notify: ", info.file(), ":", info.line(), ": ", info.tag(), ": ", info.what());
|
testspr::print_ln("trace-stack notify: ", info);
|
||||||
if (info.tag() == "assertion-failed") {
|
if (info.tag() == "assertion-failed") {
|
||||||
testspr::trace_stack::instance().print();
|
testspr::trace_stack::instance().print();
|
||||||
testspr::trace_record::instance().print();
|
testspr::trace_record::instance().print();
|
||||||
|
@ -304,9 +325,9 @@ namespace testspr {
|
||||||
std::copy(begin(), end(), out);
|
std::copy(begin(), end(), out);
|
||||||
}
|
}
|
||||||
SPROUT_NON_CONSTEXPR void print() const {
|
SPROUT_NON_CONSTEXPR void print() const {
|
||||||
testspr::print_ln("trace-stack current: size:", size(), ":");
|
testspr::print_ln("trace-stack current: size:", size(), ':');
|
||||||
for (const_iterator it = cbegin(), last = cend(); it != last; ++it) {
|
for (const_iterator it = cbegin(), last = cend(); it != last; ++it) {
|
||||||
testspr::print_ln(" ", it->file(), ":", it->line(), ": ", it->tag(), ": ", it->what());
|
testspr::print_ln(" ", *it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,6 +572,12 @@ namespace testspr {
|
||||||
# define TESTSPR_TRACE_MARK(name) \
|
# define TESTSPR_TRACE_MARK(name) \
|
||||||
((void)testspr::trace_stack::instance().notify_mark(testspr::to_string(name), __FILE__, __LINE__))
|
((void)testspr::trace_stack::instance().notify_mark(testspr::to_string(name), __FILE__, __LINE__))
|
||||||
|
|
||||||
|
//
|
||||||
|
// TESTSPR_PRINT_CURRENT
|
||||||
|
//
|
||||||
|
# define TESTSPR_PRINT_CURRENT(name) \
|
||||||
|
((void)testspr::print_ln(testspr::trace_info(__FILE__, __LINE__, "current", name)))
|
||||||
|
|
||||||
//
|
//
|
||||||
// TESTSPR_PRINT_TRACE_STACK
|
// TESTSPR_PRINT_TRACE_STACK
|
||||||
// TESTSPR_PRINT_TRACE_RECORD
|
// TESTSPR_PRINT_TRACE_RECORD
|
||||||
|
@ -560,6 +587,12 @@ namespace testspr {
|
||||||
# define TESTSPR_PRINT_TRACE_RECORD() \
|
# define TESTSPR_PRINT_TRACE_RECORD() \
|
||||||
((void)testspr::trace_record::instance().print())
|
((void)testspr::trace_record::instance().print())
|
||||||
|
|
||||||
|
//
|
||||||
|
// TESTSPR_PRINT_STRATIFIED_TRACE_RECORD
|
||||||
|
//
|
||||||
|
# define TESTSPR_PRINT_STRATIFIED_TRACE_RECORD() \
|
||||||
|
((void)testspr::trace_record::instance().print_stratified())
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// TESTSPR_ENABLE_PRINT_ON_ENTRY
|
// TESTSPR_ENABLE_PRINT_ON_ENTRY
|
||||||
|
|
Loading…
Reference in a new issue