From b04dea6002c3707163ba52514723c9204de5c4f0 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 23 Apr 2014 01:27:03 +0900 Subject: [PATCH] add and compatible constexpr functions --- README.rst | 2 +- sprout/cstring.hpp | 7 +++ sprout/cstring/memchr.hpp | 74 +++++++++++-------------------- sprout/cstring/memcmp.hpp | 21 +++++---- sprout/cstring/memcpy.hpp | 39 ++++++++++++++++ sprout/cstring/memmove.hpp | 39 ++++++++++++++++ sprout/cstring/memset.hpp | 39 ++++++++++++++++ sprout/cstring/strcat.hpp | 41 +++++++++++++++++ sprout/cstring/strcoll.hpp | 1 + sprout/cstring/strcpy.hpp | 39 ++++++++++++++++ sprout/cstring/strncat.hpp | 49 ++++++++++++++++++++ sprout/cstring/strncmp.hpp | 1 + sprout/cstring/strncpy.hpp | 49 ++++++++++++++++++++ sprout/cwchar.hpp | 7 +++ sprout/cwchar/wcscat.hpp | 24 ++++++++++ sprout/cwchar/wcscpy.hpp | 24 ++++++++++ sprout/cwchar/wcsncat.hpp | 24 ++++++++++ sprout/cwchar/wcsncpy.hpp | 24 ++++++++++ sprout/cwchar/wmemchr.hpp | 39 ++-------------- sprout/cwchar/wmemcmp.hpp | 9 +--- sprout/cwchar/wmemcpy.hpp | 24 ++++++++++ sprout/cwchar/wmemmove.hpp | 24 ++++++++++ sprout/cwchar/wmemset.hpp | 24 ++++++++++ sprout/range/numeric/fft/fft.hpp | 2 +- sprout/range/numeric/fft/ifft.hpp | 2 +- testspr/header_all.hpp | 1 + 26 files changed, 526 insertions(+), 103 deletions(-) create mode 100644 sprout/cstring/memcpy.hpp create mode 100644 sprout/cstring/memmove.hpp create mode 100644 sprout/cstring/memset.hpp create mode 100644 sprout/cstring/strcat.hpp create mode 100644 sprout/cstring/strcpy.hpp create mode 100644 sprout/cstring/strncat.hpp create mode 100644 sprout/cstring/strncpy.hpp create mode 100644 sprout/cwchar/wcscat.hpp create mode 100644 sprout/cwchar/wcscpy.hpp create mode 100644 sprout/cwchar/wcsncat.hpp create mode 100644 sprout/cwchar/wcsncpy.hpp create mode 100644 sprout/cwchar/wmemcpy.hpp create mode 100644 sprout/cwchar/wmemmove.hpp create mode 100644 sprout/cwchar/wmemset.hpp diff --git a/README.rst b/README.rst index e7eaf61f..e24dbf61 100644 --- a/README.rst +++ b/README.rst @@ -35,7 +35,7 @@ Supported Compilers Linux: -* GCC, C++11 mode: 4.7.0, 4.7.1, 4.7.2, 4.7.3, 4.8.0, 4.8.1, 4.8.2 +* GCC, C++11 mode: 4.7.0, 4.7.1, 4.7.2, 4.7.3, 4.8.0, 4.8.1, 4.8.2, 4.9.0 * Clang, C++11 mode: 3.2, 3.3, 3.4 ******************************************************************************* diff --git a/sprout/cstring.hpp b/sprout/cstring.hpp index 4309a02b..02b3f876 100644 --- a/sprout/cstring.hpp +++ b/sprout/cstring.hpp @@ -9,6 +9,12 @@ #define SPROUT_CSTRING_HPP #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -20,6 +26,7 @@ #include #include #include +#include #include #endif // #ifndef SPROUT_CSTRING_HPP diff --git a/sprout/cstring/memchr.hpp b/sprout/cstring/memchr.hpp index 5aeca64e..3835eed8 100644 --- a/sprout/cstring/memchr.hpp +++ b/sprout/cstring/memchr.hpp @@ -18,19 +18,6 @@ namespace sprout { namespace detail { - inline SPROUT_CONSTEXPR unsigned char const* - memchr_impl(unsigned char const* found, unsigned char const* last) { - return found == last ? nullptr - : found - ; - } - inline SPROUT_CONSTEXPR unsigned char* - memchr_impl(unsigned char* found, unsigned char* last) { - return found == last ? nullptr - : found - ; - } - template struct memchr_result { private: @@ -40,6 +27,27 @@ namespace sprout { public: typedef decltype(check(std::declval())) type; }; + + template + inline SPROUT_CONSTEXPR PtrIterator + memchr_impl(PtrIterator found, PtrIterator last) { + return found == last ? nullptr + : found + ; + } + template + inline SPROUT_CONSTEXPR PtrIterator + memchr(PtrIterator s, T c, std::size_t n) { + return sprout::detail::memchr_impl( + sprout::ptr_unindex( + sprout::find( + sprout::ptr_index(s), sprout::ptr_index(s, n), + c + ) + ), + s + n + ); + } } // namespace detail // 7.21.5.1 memchr 関数 @@ -50,28 +58,12 @@ namespace sprout { #if 0 inline SPROUT_CONSTEXPR void const* memchr(void const* 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 - ); + return sprout::detail::memchr(static_cast(s), static_cast(c), n); } inline SPROUT_CONSTEXPR void* memchr(void* 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 - ); + return sprout::detail::memchr(static_cast(s), static_cast(c), n); } #endif template< @@ -80,15 +72,7 @@ namespace sprout { > 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 - ); + return sprout::detail::memchr(static_cast(s), static_cast(c), n); } template< @@ -97,15 +81,7 @@ namespace sprout { > 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 - ); + return sprout::detail::memchr(static_cast(s), static_cast(c), n); } } // namespace sprout diff --git a/sprout/cstring/memcmp.hpp b/sprout/cstring/memcmp.hpp index a4877558..f56bc684 100644 --- a/sprout/cstring/memcmp.hpp +++ b/sprout/cstring/memcmp.hpp @@ -16,6 +16,17 @@ #include namespace sprout { + namespace detail { + template + inline SPROUT_CONSTEXPR int + memcmp(PtrIterator s1, PtrIterator s2, std::size_t n) { + return sprout::tristate_lexicographical_compare( + sprout::ptr_index(s1), sprout::ptr_index(s1, n), + sprout::ptr_index(s2), sprout::ptr_index(s2, n) + ); + } + } // namespace detail + // 7.21.4.1 memcmp 関数 // // recursion depth: @@ -24,10 +35,7 @@ namespace sprout { #if 0 inline SPROUT_CONSTEXPR int memcmp(void const* s1, void const* 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) - ); + return sprout::detail::memcmp(static_cast(s1), static_cast(s2), n); } #endif template< @@ -36,10 +44,7 @@ namespace sprout { > 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) - ); + return sprout::detail::memcmp(static_cast(s1), static_cast(s2), n); } } // namespace sprout diff --git a/sprout/cstring/memcpy.hpp b/sprout/cstring/memcpy.hpp new file mode 100644 index 00000000..8f80c628 --- /dev/null +++ b/sprout/cstring/memcpy.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_MEMCPY_HPP +#define SPROUT_CSTRING_MEMCPY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR PtrIterator + memcpy(PtrIterator s1, ConstPtrIterator s2, std::size_t n) { + sprout::copy(s2, s2 + n, s1); + return s1; + } + } // namespace detail + + // 7.21.2.1 The memcpy function + // + template< + typename T, typename CT, + typename sprout::enabler_if::value && std::is_convertible::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR void* + memcpy(T s1, CT s2, std::size_t n) { + return sprout::detail::memcpy(static_cast(s1), static_cast(s2), n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_MEMCPY_HPP diff --git a/sprout/cstring/memmove.hpp b/sprout/cstring/memmove.hpp new file mode 100644 index 00000000..c05ed6d2 --- /dev/null +++ b/sprout/cstring/memmove.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_MEMMOVE_HPP +#define SPROUT_CSTRING_MEMMOVE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR PtrIterator + memmove(PtrIterator s1, ConstPtrIterator s2, std::size_t n) { + sprout::copy_backward(s2, s2 + n, s1); + return s1; + } + } // namespace detail + + // 7.21.2.2 The memmove function + // + template< + typename T, typename CT, + typename sprout::enabler_if::value && std::is_convertible::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR void* + memmove(T s1, CT s2, std::size_t n) { + return sprout::detail::memmove(static_cast(s1), static_cast(s2), n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_MEMMOVE_HPP diff --git a/sprout/cstring/memset.hpp b/sprout/cstring/memset.hpp new file mode 100644 index 00000000..f0218608 --- /dev/null +++ b/sprout/cstring/memset.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_MEMSET_HPP +#define SPROUT_CSTRING_MEMSET_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR PtrIterator + memset(PtrIterator s, T c, std::size_t n) { + sprout::fill(s, s + n, c); + return s; + } + } // namespace detail + + // 7.21.6.1 The memset function + // + template< + typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR void* + memset(T s, int c, std::size_t n) { + return sprout::detail::memset(static_cast(s), static_cast(c), n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_MEMSET_HPP diff --git a/sprout/cstring/strcat.hpp b/sprout/cstring/strcat.hpp new file mode 100644 index 00000000..8a634be0 --- /dev/null +++ b/sprout/cstring/strcat.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_STRCAT_HPP +#define SPROUT_CSTRING_STRCAT_HPP + +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator + strcat(OutputCStrIterator s1, CStrIterator s2) { + OutputCStrIterator result = s1; + while (*s1++) + ; + while (*s1++ = *s2++) + ; + return result; + } + } // namespace detail + + // 7.21.3.1 The strcat function + // + inline SPROUT_CXX14_CONSTEXPR char* + strcat(char* s1, char const* s2) { + return sprout::detail::strcat(s1, s2); + } + + template + inline SPROUT_CXX14_CONSTEXPR Elem* + strcat(Elem* s1, Elem const* s2) { + return sprout::detail::strcat(s1, s2); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_STRCAT_HPP diff --git a/sprout/cstring/strcoll.hpp b/sprout/cstring/strcoll.hpp index 5a1d888b..ab1cdbff 100644 --- a/sprout/cstring/strcoll.hpp +++ b/sprout/cstring/strcoll.hpp @@ -14,6 +14,7 @@ #include namespace sprout { + // 7.21.4.3 strcoll 関数 // // recursion depth: diff --git a/sprout/cstring/strcpy.hpp b/sprout/cstring/strcpy.hpp new file mode 100644 index 00000000..f191479f --- /dev/null +++ b/sprout/cstring/strcpy.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_STRCPY_HPP +#define SPROUT_CSTRING_STRCPY_HPP + +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator + strcpy(OutputCStrIterator s1, CStrIterator s2) { + OutputCStrIterator result = s1; + while (*s1++ = *s2++) + ; + return result; + } + } // namespace detail + + // 7.21.2.3 The strcpy function + // + inline SPROUT_CXX14_CONSTEXPR char* + strcpy(char* s1, char const* s2) { + return sprout::detail::strcpy(s1, s2); + } + + template + inline SPROUT_CXX14_CONSTEXPR Elem* + strcpy(Elem* s1, Elem const* s2) { + return sprout::detail::strcpy(s1, s2); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_STRCPY_HPP diff --git a/sprout/cstring/strncat.hpp b/sprout/cstring/strncat.hpp new file mode 100644 index 00000000..2aa2c46e --- /dev/null +++ b/sprout/cstring/strncat.hpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_STRNCAT_HPP +#define SPROUT_CSTRING_STRNCAT_HPP + +#include +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator + strncat(OutputCStrIterator s1, CStrIterator s2, std::size_t n) { + typedef typename std::iterator_traits::value_type value_type; + OutputCStrIterator result = s1; + while (*s1) { + ++s1; + } + while (n) { + --n; + if (!(*s1++ = *s2++)) { + break; + } + } + *s1 = value_type(); + return result; + } + } // namespace detail + + // 7.21.3.2 The strncat function + // + inline SPROUT_CXX14_CONSTEXPR char* + strncat(char* s1, char const* s2, std::size_t n) { + return sprout::detail::strncat(s1, s2, n); + } + + template + inline SPROUT_CXX14_CONSTEXPR Elem* + strncat(Elem* s1, Elem const* s2, std::size_t n) { + return sprout::detail::strncat(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_STRNCAT_HPP diff --git a/sprout/cstring/strncmp.hpp b/sprout/cstring/strncmp.hpp index 858ee43a..0c42a99d 100644 --- a/sprout/cstring/strncmp.hpp +++ b/sprout/cstring/strncmp.hpp @@ -16,6 +16,7 @@ #include namespace sprout { + // 7.21.4.4 strncmp 関数 // // recursion depth: diff --git a/sprout/cstring/strncpy.hpp b/sprout/cstring/strncpy.hpp new file mode 100644 index 00000000..7bbe0914 --- /dev/null +++ b/sprout/cstring/strncpy.hpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_STRNCPY_HPP +#define SPROUT_CSTRING_STRNCPY_HPP + +#include +#include + +namespace sprout { + namespace detail { + template + inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator + strncpy(OutputCStrIterator s1, CStrIterator s2, std::size_t n) { + typedef typename std::iterator_traits::value_type value_type; + OutputCStrIterator result = s1; + while (n) { + --n; + if (!(*s1++ = *s2++)) { + break; + } + } + while (n) { + --n; + *s1++ = value_type(); + } + return result; + } + } // namespace detail + + // 7.21.2.4 The strncpy function + // + inline SPROUT_CXX14_CONSTEXPR char* + strncpy(char* s1, char const* s2, std::size_t n) { + return sprout::detail::strncpy(s1, s2, n); + } + + template + inline SPROUT_CXX14_CONSTEXPR Elem* + strncpy(Elem* s1, Elem const* s2, std::size_t n) { + return sprout::detail::strncpy(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_STRNCPY_HPP diff --git a/sprout/cwchar.hpp b/sprout/cwchar.hpp index 5ad8216d..f2037aeb 100644 --- a/sprout/cwchar.hpp +++ b/sprout/cwchar.hpp @@ -9,6 +9,12 @@ #define SPROUT_CWCHER_HPP #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -21,5 +27,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_CWCHER_HPP diff --git a/sprout/cwchar/wcscat.hpp b/sprout/cwchar/wcscat.hpp new file mode 100644 index 00000000..47bce357 --- /dev/null +++ b/sprout/cwchar/wcscat.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_WCSCAT_HPP +#define SPROUT_CSTRING_WCSCAT_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.3.1 The wcscat function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wcscat(wchar_t* s1, wchar_t const* s2) { + return sprout::strcat(s1, s2); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_WCSCAT_HPP diff --git a/sprout/cwchar/wcscpy.hpp b/sprout/cwchar/wcscpy.hpp new file mode 100644 index 00000000..da6251f6 --- /dev/null +++ b/sprout/cwchar/wcscpy.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_WCSCPY_HPP +#define SPROUT_CSTRING_WCSCPY_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.2.1 The wcscpy function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wcscpy(wchar_t* s1, wchar_t const* s2) { + return sprout::strcpy(s1, s2); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_WCSCPY_HPP diff --git a/sprout/cwchar/wcsncat.hpp b/sprout/cwchar/wcsncat.hpp new file mode 100644 index 00000000..cfb6d61d --- /dev/null +++ b/sprout/cwchar/wcsncat.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CSTRING_WCSNCAT_HPP +#define SPROUT_CSTRING_WCSNCAT_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.3.2 The wcsncat function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wcsncat(wchar_t* s1, wchar_t const* s2, std::size_t n) { + return sprout::strncat(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTRING_WCSNCAT_HPP diff --git a/sprout/cwchar/wcsncpy.hpp b/sprout/cwchar/wcsncpy.hpp new file mode 100644 index 00000000..629b690d --- /dev/null +++ b/sprout/cwchar/wcsncpy.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CWCHAR_WCS_HPP +#define SPROUT_CWCHAR_WCS_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.2.2 The wcsncpy function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wcsncpy(wchar_t* s1, wchar_t const* s2, std::size_t n) { + return sprout::strncpy(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CWCHAR_WCS_HPP diff --git a/sprout/cwchar/wmemchr.hpp b/sprout/cwchar/wmemchr.hpp index ed0dd878..62fa4c2a 100644 --- a/sprout/cwchar/wmemchr.hpp +++ b/sprout/cwchar/wmemchr.hpp @@ -8,27 +8,10 @@ #ifndef SPROUT_CWCHAR_WMEMCHR_HPP #define SPROUT_CWCHAR_WMEMCHR_HPP -#include #include -#include -#include +#include namespace sprout { - namespace detail { - inline SPROUT_CONSTEXPR wchar_t const* - wmemchr_impl(wchar_t const* found, wchar_t const* last) { - return found == last ? nullptr - : found - ; - } - inline SPROUT_CONSTEXPR wchar_t* - wmemchr_impl(wchar_t* found, wchar_t* last) { - return found == last ? nullptr - : found - ; - } - } // namespace detail - // // wmemchr // @@ -37,28 +20,12 @@ namespace sprout { // inline SPROUT_CONSTEXPR wchar_t const* wmemchr(wchar_t const* s, wchar_t c, size_t n) { - return sprout::detail::wmemchr_impl( - sprout::ptr_unindex( - sprout::find( - sprout::ptr_index(s), sprout::ptr_index(s, n), - c - ) - ), - s + n - ); + return sprout::detail::memchr(s, c, n); } inline SPROUT_CONSTEXPR wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n) { - return sprout::detail::wmemchr_impl( - sprout::ptr_unindex( - sprout::find( - sprout::ptr_index(s), sprout::ptr_index(s, n), - c - ) - ), - s + n - ); + return sprout::detail::memchr(s, c, n); } } // namespace sprout diff --git a/sprout/cwchar/wmemcmp.hpp b/sprout/cwchar/wmemcmp.hpp index af2f5b84..5747d923 100644 --- a/sprout/cwchar/wmemcmp.hpp +++ b/sprout/cwchar/wmemcmp.hpp @@ -8,10 +8,8 @@ #ifndef SPROUT_CWCHAR_WMEMCMP_HPP #define SPROUT_CWCHAR_WMEMCMP_HPP -#include #include -#include -#include +#include namespace sprout { // @@ -22,10 +20,7 @@ namespace sprout { // inline SPROUT_CONSTEXPR int wmemcmp(wchar_t const* s1, wchar_t const* s2, std::size_t n) { - return sprout::tristate_lexicographical_compare( - sprout::ptr_index(s1), sprout::ptr_index(s1, n), - sprout::ptr_index(s2), sprout::ptr_index(s2, n) - ); + return sprout::detail::memcmp(s1, s2, n); } } // namespace sprout diff --git a/sprout/cwchar/wmemcpy.hpp b/sprout/cwchar/wmemcpy.hpp new file mode 100644 index 00000000..d2b367d2 --- /dev/null +++ b/sprout/cwchar/wmemcpy.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CWCHAR_WMEMCPY_HPP +#define SPROUT_CWCHAR_WMEMCPY_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.2.3 The wmemcpy function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wmemcpy(wchar_t* s1, wchar_t const* s2, std::size_t n) { + return sprout::detail::memcpy(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CWCHAR_WMEMCPY_HPP diff --git a/sprout/cwchar/wmemmove.hpp b/sprout/cwchar/wmemmove.hpp new file mode 100644 index 00000000..201fc6c9 --- /dev/null +++ b/sprout/cwchar/wmemmove.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CWCHAR_WMEMMOVE_HPP +#define SPROUT_CWCHAR_WMEMMOVE_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.2.4 The wmemmove function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wmemmove(wchar_t* s1, wchar_t const* s2, std::size_t n) { + return sprout::detail::memmove(s1, s2, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CWCHAR_WMEMMOVE_HPP diff --git a/sprout/cwchar/wmemset.hpp b/sprout/cwchar/wmemset.hpp new file mode 100644 index 00000000..4b649fe7 --- /dev/null +++ b/sprout/cwchar/wmemset.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2011-2014 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_CWCHAR_WMEMSET_HPP +#define SPROUT_CWCHAR_WMEMSET_HPP + +#include +#include + +namespace sprout { + + // 7.24.4.6.2 The wmemset function + // + inline SPROUT_CXX14_CONSTEXPR wchar_t* + wmemset(wchar_t* s, wchar_t c, std::size_t n) { + return sprout::detail::memset(s, c, n); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CWCHAR_WMEMSET_HPP diff --git a/sprout/range/numeric/fft/fft.hpp b/sprout/range/numeric/fft/fft.hpp index e3b88f9b..af598374 100644 --- a/sprout/range/numeric/fft/fft.hpp +++ b/sprout/range/numeric/fft/fft.hpp @@ -19,7 +19,7 @@ namespace sprout { // fft // template - inline SPROUT_CONSTEXPR void + inline SPROUT_CXX14_CONSTEXPR void fft(RandomAccessRange&& rng) { sprout::fft(sprout::begin(SPROUT_FORWARD(RandomAccessRange, rng)), sprout::end(SPROUT_FORWARD(RandomAccessRange, rng))); } diff --git a/sprout/range/numeric/fft/ifft.hpp b/sprout/range/numeric/fft/ifft.hpp index 9f037dcf..fb18667f 100644 --- a/sprout/range/numeric/fft/ifft.hpp +++ b/sprout/range/numeric/fft/ifft.hpp @@ -19,7 +19,7 @@ namespace sprout { // ifft // template - inline SPROUT_CONSTEXPR void + inline SPROUT_CXX14_CONSTEXPR void ifft(RandomAccessRange&& rng) { sprout::ifft(sprout::begin(SPROUT_FORWARD(RandomAccessRange, rng)), sprout::end(SPROUT_FORWARD(RandomAccessRange, rng))); } diff --git a/testspr/header_all.hpp b/testspr/header_all.hpp index c8881083..5e57b5ff 100644 --- a/testspr/header_all.hpp +++ b/testspr/header_all.hpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include