diff --git a/libs/cstring/test/memchr.cpp b/libs/cstring/test/memchr.cpp index 0eca7887..71d3b19e 100644 --- a/libs/cstring/test/memchr.cpp +++ b/libs/cstring/test/memchr.cpp @@ -14,7 +14,8 @@ namespace testspr { { SPROUT_STATIC_CONSTEXPR auto found = sprout::memchr(buf, b, 12); - TESTSPR_BOTH_ASSERT(sprout::distance(buf, reinterpret_cast(found)) == 8); + TESTSPR_BOTH_ASSERT(buf + 8 == found); +// TESTSPR_BOTH_ASSERT(sprout::distance(buf, reinterpret_cast(found)) == 8); } } } diff --git a/sprout/cstring/memchr.hpp b/sprout/cstring/memchr.hpp index cc44da09..e0375674 100644 --- a/sprout/cstring/memchr.hpp +++ b/sprout/cstring/memchr.hpp @@ -6,6 +6,10 @@ #include #include +#include +#include +#include + namespace sprout { namespace detail { inline SPROUT_CONSTEXPR unsigned char const* @@ -20,6 +24,16 @@ namespace sprout { : found ; } + + template + struct memchr_result { + private: + static void const* check(void const*); + static void* check(void*); + static void check(...); + public: + typedef decltype(check(std::declval())) type; + }; } // namespace detail // 7.21.5.1 memchr ֐ @@ -27,6 +41,7 @@ namespace sprout { // recursion depth: // O(log N) // +#if 0 inline SPROUT_CONSTEXPR void const* memchr(void const* s, int c, std::size_t n) { return sprout::detail::memchr_impl( @@ -52,6 +67,40 @@ namespace sprout { static_cast(s) + n ); } +#endif + template< + typename T, + typename sprout::enabler_if::type, void const*>::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR void const* + memchr(T s, int c, std::size_t n) { + return sprout::detail::memchr_impl( + sprout::ptr_unindex( + sprout::find( + sprout::ptr_index(static_cast(s)), sprout::ptr_index(static_cast(s), n), + static_cast(c) + ) + ), + static_cast(s) + n + ); + } + + template< + typename T, + typename sprout::enabler_if::type, void*>::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR void* + memchr(T s, int c, std::size_t n) { + return sprout::detail::memchr_impl( + sprout::ptr_unindex( + sprout::find( + sprout::ptr_index(static_cast(s)), sprout::ptr_index(static_cast(s), n), + static_cast(c) + ) + ), + static_cast(s) + n + ); + } } // namespace sprout #endif // #ifndef SPROUT_CSTRING_MEMCHR_HPP diff --git a/sprout/cstring/memcmp.hpp b/sprout/cstring/memcmp.hpp index a38215ac..1f15d911 100644 --- a/sprout/cstring/memcmp.hpp +++ b/sprout/cstring/memcmp.hpp @@ -6,12 +6,16 @@ #include #include +#include +#include + namespace sprout { // 7.21.4.1 memcmp ֐ // // recursion depth: // O(log(N1+N2)) // +#if 0 inline SPROUT_CONSTEXPR int memcmp(void const* s1, void const* s2, std::size_t n) { return sprout::tristate_lexicographical_compare( @@ -19,6 +23,18 @@ namespace sprout { sprout::ptr_index(static_cast(s2)), sprout::ptr_index(static_cast(s2), n) ); } +#endif + template< + typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR int + memcmp(T s1, T s2, std::size_t n) { + return sprout::tristate_lexicographical_compare( + sprout::ptr_index(static_cast(s1)), sprout::ptr_index(static_cast(s1), n), + sprout::ptr_index(static_cast(s2)), sprout::ptr_index(static_cast(s2), n) + ); + } } // namespace sprout #endif // #ifndef SPROUT_CSTRING_MEMCMP_HPP diff --git a/sprout/forward_clist.hpp b/sprout/forward_clist.hpp index 37b725df..7513de13 100644 --- a/sprout/forward_clist.hpp +++ b/sprout/forward_clist.hpp @@ -317,9 +317,7 @@ namespace sprout { p = &(*p)->next; } } - SPROUT_CXX14_CONSTEXPR forward_clist(forward_clist&& x) - : fst(sprout::move(x.fst)) - {} + SPROUT_CXX14_CONSTEXPR forward_clist(forward_clist&& x) = default; SPROUT_CXX14_CONSTEXPR forward_clist& operator=(forward_clist&& x) { fst = sprout::move(x.fst); return *this; diff --git a/sprout/utility/string_ref/conversion.hpp b/sprout/utility/string_ref/conversion.hpp index 394f1753..dfd19f4e 100644 --- a/sprout/utility/string_ref/conversion.hpp +++ b/sprout/utility/string_ref/conversion.hpp @@ -1,7 +1,7 @@ #ifndef SPROUT_UTILITY_STRING_REF_CONVERSION_HPP #define SPROUT_UTILITY_STRING_REF_CONVERSION_HPP -#include +#include #include #endif // #ifndef SPROUT_UTILITY_STRING_REF_CONVERSION_HPP diff --git a/sprout/utility/string_view.hpp b/sprout/utility/string_view.hpp new file mode 100644 index 00000000..2875bb86 --- /dev/null +++ b/sprout/utility/string_view.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_UTILITY_STRING_VIEW_HPP +#define SPROUT_UTILITY_STRING_VIEW_HPP + +#include +#include + +#endif // #ifndef SPROUT_UTILITY_STRING_VIEW_HPP diff --git a/sprout/weed/attr_cnv/result_of/shift_left.hpp b/sprout/weed/attr_cnv/result_of/shift_left.hpp index e5793a39..44519d7c 100644 --- a/sprout/weed/attr_cnv/result_of/shift_left.hpp +++ b/sprout/weed/attr_cnv/result_of/shift_left.hpp @@ -66,7 +66,7 @@ namespace sprout { sprout::weed::detail::is_elem_and_container::value >::type > - : public sprout::fixed::result_of::push_front + : public sprout::fixed::result_of::push_front {}; // tuple >> tuple -> tuple template @@ -99,7 +99,7 @@ namespace sprout { sprout::weed::detail::is_elem_and_tuple::value >::type > - : public sprout::tuples::result_of::push_front + : public sprout::tuples::result_of::push_front {}; // V >> V -> container template diff --git a/sprout/weed/attr_cnv/shift_left.hpp b/sprout/weed/attr_cnv/shift_left.hpp index 778ed774..383af1c8 100644 --- a/sprout/weed/attr_cnv/shift_left.hpp +++ b/sprout/weed/attr_cnv/shift_left.hpp @@ -51,7 +51,7 @@ namespace sprout { sprout::weed::detail::is_elem_and_container::value, typename sprout::weed::attr_cnv::result_of::shift_left::type >::type shift_left(T const& t, U const& u) { - return sprout::fixed::push_front(t, u); + return sprout::fixed::push_front(u, t); } // tuple >> tuple -> tuple template @@ -75,7 +75,7 @@ namespace sprout { sprout::weed::detail::is_elem_and_tuple::value, typename sprout::weed::attr_cnv::result_of::shift_left::type >::type shift_left(T const& t, U const& u) { - return sprout::tuples::push_front(t, u); + return sprout::tuples::push_front(u, t); } // V >> V -> container template