From 54920b33896a9f6fe35f38b84a4ee9452d2a1ae5 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 10 Jul 2014 17:08:33 +0900 Subject: [PATCH] add complex tuple and container support --- sprout/complex.hpp | 2 + sprout/complex/complex.hpp | 162 ++++++++++++++++++++++++++------ sprout/complex/container.hpp | 44 +++++++++ sprout/complex/tuple.hpp | 111 ++++++++++++++++++++++ sprout/cstdlib/ascii_to_int.hpp | 22 ++--- sprout/cstdlib/str_to_float.hpp | 48 +++++----- sprout/cstdlib/str_to_int.hpp | 32 +++---- sprout/cstring/strcat.hpp | 8 +- sprout/cstring/strcpy.hpp | 8 +- sprout/cstring/strncat.hpp | 10 +- sprout/cstring/strncpy.hpp | 10 +- 11 files changed, 357 insertions(+), 100 deletions(-) create mode 100644 sprout/complex/container.hpp create mode 100644 sprout/complex/tuple.hpp diff --git a/sprout/complex.hpp b/sprout/complex.hpp index 2bc5f937..c4fadb10 100644 --- a/sprout/complex.hpp +++ b/sprout/complex.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/sprout/complex/complex.hpp b/sprout/complex/complex.hpp index 3c05d066..b00cd845 100644 --- a/sprout/complex/complex.hpp +++ b/sprout/complex/complex.hpp @@ -9,6 +9,7 @@ #define SPROUT_COMPLEX_COMPLEX_HPP #include +#include namespace sprout { template @@ -27,100 +28,199 @@ namespace sprout { // template class complex { + private: + typedef sprout::array array_type; public: typedef T value_type; + typedef typename array_type::iterator iterator; + typedef typename array_type::const_iterator const_iterator; + typedef typename array_type::reference reference; + typedef typename array_type::const_reference const_reference; + typedef typename array_type::size_type size_type; + typedef typename array_type::pointer pointer; + typedef typename array_type::const_pointer const_pointer; + typedef typename array_type::pointer reverse_iterator; + typedef typename array_type::pointer const_reverse_iterator; + public: + SPROUT_STATIC_CONSTEXPR size_type static_size = array_type::static_size; private: - T re_; - T im_; + array_type elems_; public: SPROUT_CONSTEXPR complex(T const& re = T(), T const& im = T()) SPROUT_NOEXCEPT - : re_(re), im_(im) + : elems_{{re, im}} {} - complex(complex const&) = default; + SPROUT_CXX14_CONSTEXPR complex(complex const&) = default; template SPROUT_CONSTEXPR complex(complex const& other) SPROUT_NOEXCEPT - : re_(other.real()), im_(other.imag()) + : elems_{{other.real(), other.imag()}} {} SPROUT_CONSTEXPR T const& real() const SPROUT_NOEXCEPT { - return re_; + return elems_[0]; } SPROUT_CXX14_CONSTEXPR T& real() SPROUT_NOEXCEPT { - return re_; + return elems_[0]; } SPROUT_CXX14_CONSTEXPR void real(T re) SPROUT_NOEXCEPT { - re_ = re; + elems_[0] = re; } SPROUT_CONSTEXPR T const& imag() const SPROUT_NOEXCEPT { - return im_; + return elems_[1]; } SPROUT_CXX14_CONSTEXPR T& imag() SPROUT_NOEXCEPT { - return im_; + return elems_[1]; } SPROUT_CXX14_CONSTEXPR void imag(T im) SPROUT_NOEXCEPT { - im_ = im; + elems_[1] = im; } SPROUT_CXX14_CONSTEXPR complex& operator=(T const& rhs) SPROUT_NOEXCEPT { - re_ = rhs; - im_ = T(); + real() = rhs; + imag() = T(); return *this; } SPROUT_CXX14_CONSTEXPR complex& operator+=(T const& rhs) SPROUT_NOEXCEPT { - re_ += rhs; + real() += rhs; return *this; } SPROUT_CXX14_CONSTEXPR complex& operator-=(T const& rhs) SPROUT_NOEXCEPT { - re_ -= rhs; + real() -= rhs; return *this; } SPROUT_CXX14_CONSTEXPR complex& operator*=(T const& rhs) SPROUT_NOEXCEPT { - re_ *= rhs; - im_ *= rhs; + real() *= rhs; + imag() *= rhs; return *this; } SPROUT_CXX14_CONSTEXPR complex& operator/=(T const& rhs) SPROUT_NOEXCEPT { - re_ /= rhs; - im_ /= rhs; + real() /= rhs; + imag() /= rhs; return *this; } SPROUT_CXX14_CONSTEXPR complex& operator=(complex const& rhs) SPROUT_NOEXCEPT { - re_ = rhs.real(); - im_ = rhs.imag(); + real() = rhs.real(); + imag() = rhs.imag(); return *this; } template SPROUT_CXX14_CONSTEXPR complex& operator=(complex const& rhs) SPROUT_NOEXCEPT { - re_ = rhs.real(); - im_ = rhs.imag(); + real() = rhs.real(); + imag() = rhs.imag(); return *this; } template SPROUT_CXX14_CONSTEXPR complex& operator+=(complex const& rhs) SPROUT_NOEXCEPT { - re_ += rhs.real(); - im_ += rhs.imag(); + real() += rhs.real(); + imag() += rhs.imag(); return *this; } template SPROUT_CXX14_CONSTEXPR complex& operator-=(complex const& rhs) SPROUT_NOEXCEPT { - re_ -= rhs.real(); - im_ -= rhs.imag(); + real() -= rhs.real(); + imag() -= rhs.imag(); return *this; } template SPROUT_CXX14_CONSTEXPR complex& operator*=(complex const& rhs) SPROUT_NOEXCEPT { return *this = complex( - re_ * rhs.real() - im_ * rhs.imag(), - re_ * rhs.imag() + im_ * rhs.real() + real() * rhs.real() - imag() * rhs.imag(), + real() * rhs.imag() + imag() * rhs.real() ); } template SPROUT_CXX14_CONSTEXPR complex& operator/=(complex const& rhs) SPROUT_NOEXCEPT { T n = sprout::detail::complex_norm(rhs); return *this = complex( - (re_ * rhs.real() + im_ * rhs.imag()) / n, - (im_ * rhs.real() - re_ * rhs.imag()) / n + (real() * rhs.real() + imag() * rhs.imag()) / n, + (imag() * rhs.real() - real() * rhs.imag()) / n ); } + // iterators: + SPROUT_CXX14_CONSTEXPR iterator begin() SPROUT_NOEXCEPT { + return elems_.begin(); + } + SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT { + return elems_.begin(); + } + SPROUT_CXX14_CONSTEXPR iterator end() SPROUT_NOEXCEPT { + return elems_.end(); + } + SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT { + return elems_.end(); + } + SPROUT_CXX14_CONSTEXPR reverse_iterator rbegin() SPROUT_NOEXCEPT { + return elems_.rbegin(); + } + SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { + return elems_.rbegin(); + } + SPROUT_CXX14_CONSTEXPR reverse_iterator rend() SPROUT_NOEXCEPT { + return elems_.rend(); + } + SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + return elems_.rend(); + } + SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT { + return elems_.cbegin(); + } + SPROUT_CONSTEXPR const_iterator cend() const SPROUT_NOEXCEPT { + return elems_.cbegin(); + } + SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { + return elems_.crbegin(); + } + SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + return elems_.crend(); + } + // capacity: + SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { + return elems_.size(); + } + SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { + return elems_.max_size(); + } + SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { + return elems_.empty(); + } + // element access: + SPROUT_CXX14_CONSTEXPR reference operator[](size_type i) { + return elems_[i]; + } + SPROUT_CONSTEXPR const_reference operator[](size_type i) const { + return elems_[i]; + } + SPROUT_CXX14_CONSTEXPR reference at(size_type i) { + return elems_.at(i); + } + SPROUT_CONSTEXPR const_reference at(size_type i) const { + return elems_.at(i); + } + SPROUT_CXX14_CONSTEXPR reference front() { + return elems_.front(); + } + SPROUT_CONSTEXPR const_reference front() const { + return elems_.front(); + } + SPROUT_CXX14_CONSTEXPR reference back() { + return elems_.back(); + } + SPROUT_CONSTEXPR const_reference back() const { + return elems_.back(); + } + + SPROUT_CXX14_CONSTEXPR pointer data() SPROUT_NOEXCEPT { + return elems_.data(); + } + SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT { + return elems_.data(); + } + SPROUT_CXX14_CONSTEXPR pointer c_array() SPROUT_NOEXCEPT { + return elems_.c_array(); + } + SPROUT_CONSTEXPR const_pointer c_array() const SPROUT_NOEXCEPT { + return elems_.c_array(); + } }; + template + SPROUT_CONSTEXPR_OR_CONST typename sprout::complex::size_type sprout::complex::static_size; } // namespace sprout #endif // #ifndef SPROUT_COMPLEX_COMPLEX_HPP diff --git a/sprout/complex/container.hpp b/sprout/complex/container.hpp new file mode 100644 index 00000000..37e3f189 --- /dev/null +++ b/sprout/complex/container.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + 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_COMPLEX_CONTAINER_HPP +#define SPROUT_COMPLEX_CONTAINER_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // container_construct_traits + // + template + struct container_construct_traits > { + public: + typedef sprout::complex copied_type; + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&& cont) { + return SPROUT_FORWARD(Cont, cont); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + typedef sprout::detail::make_construct_impl impl_type; + return copied_type(SPROUT_FORWARD(Args, args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&&, typename sprout::container_traits >::difference_type size, Args&&... args) { + return copied_type(SPROUT_FORWARD(Args, args)...); + } + }; +} // namespace sprout + +#endif // #ifndef SPROUT_COMPLEX_CONTAINER_HPP diff --git a/sprout/complex/tuple.hpp b/sprout/complex/tuple.hpp new file mode 100644 index 00000000..75f50297 --- /dev/null +++ b/sprout/complex/tuple.hpp @@ -0,0 +1,111 @@ +/*============================================================================= + 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_COMPLEX_TUPLE_HPP +#define SPROUT_COMPLEX_TUPLE_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + namespace detail { + template + struct tuple_element_impl; + template + struct tuple_element_impl > + : public sprout::detail::nil_base + {}; + template + struct tuple_element_impl<0, sprout::complex > + : public sprout::identity + {}; + template + struct tuple_element_impl<1, sprout::complex > + : public sprout::identity + {}; + + template + struct get_impl; + template + struct get_impl<0, sprout::complex > { + public: + SPROUT_CONSTEXPR T& operator()(sprout::complex& t) const { + return t.real(); + } + SPROUT_CONSTEXPR T const& operator()(sprout::complex const& t) const { + return t.real(); + } + }; + template + struct get_impl<1, sprout::complex > { + public: + SPROUT_CONSTEXPR T& operator()(sprout::complex& t) const { + return t.imag(); + } + SPROUT_CONSTEXPR T const& operator()(sprout::complex const& t) const { + return t.imag(); + } + }; + } // namespace detail + } // namespace tuples +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // tuple_size + // + template + struct tuple_size > + : public sprout::integral_constant + {}; + + // + // tuple_element + // + template + struct tuple_element > + : public sprout::tuples::detail::tuple_element_impl > + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + +namespace sprout { + // + // tuple_get + // + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type& + tuple_get(sprout::complex& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl >()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type const& + tuple_get(sprout::complex const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl >()(t); + } + template + inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type&& + tuple_get(sprout::complex&& t) SPROUT_NOEXCEPT { + return sprout::move(sprout::tuples::get(t)); + } +} // namespace sprout + +#endif // #ifndef SPROUT_COMPLEX_TUPLE_HPP diff --git a/sprout/cstdlib/ascii_to_int.hpp b/sprout/cstdlib/ascii_to_int.hpp index 742e5e23..1252668c 100644 --- a/sprout/cstdlib/ascii_to_int.hpp +++ b/sprout/cstdlib/ascii_to_int.hpp @@ -19,44 +19,44 @@ namespace sprout { namespace detail { // Copyright (c) 2011 osyo-manga : http://d.hatena.ne.jp/osyo-manga/ - template + template inline SPROUT_CONSTEXPR IntType - ascii_to_int_impl(CStrIterator str, IntType val, bool negative) { + ascii_to_int_impl(NullTerminatedIterator str, IntType val, bool negative) { return !sprout::ascii::isdigit(*str) ? negative ? -val : val - : val > (sprout::numeric_limits::max() - (*str - static_cast::value_type>('0')) - (negative ? 1 : 0)) / 10 + : val > (sprout::numeric_limits::max() - (*str - static_cast::value_type>('0')) - (negative ? 1 : 0)) / 10 ? (negative ? sprout::numeric_limits::min() : sprout::numeric_limits::max()) : sprout::detail::ascii_to_int_impl( sprout::next(str), - val * 10 + (*str - static_cast::value_type>('0')), + val * 10 + (*str - static_cast::value_type>('0')), negative ) ; } - template + template inline SPROUT_CONSTEXPR typename std::enable_if< std::is_unsigned::value, IntType >::type - ascii_to_int(CStrIterator str) { + ascii_to_int(NullTerminatedIterator str) { return sprout::ascii::isspace(*str) ? sprout::detail::ascii_to_int(sprout::next(str)) - : *str == static_cast::value_type>('+') + : *str == static_cast::value_type>('+') ? sprout::detail::ascii_to_int_impl(sprout::next(str), IntType(), false) : sprout::detail::ascii_to_int_impl(str, IntType(), false) ; } - template + template inline SPROUT_CONSTEXPR typename std::enable_if< std::is_signed::value, IntType >::type - ascii_to_int(CStrIterator str) { + ascii_to_int(NullTerminatedIterator str) { return sprout::ascii::isspace(*str) ? sprout::detail::ascii_to_int(sprout::next(str)) - : *str == static_cast::value_type>('-') + : *str == static_cast::value_type>('-') ? sprout::detail::ascii_to_int_impl(sprout::next(str), IntType(), true) - : *str == static_cast::value_type>('+') + : *str == static_cast::value_type>('+') ? sprout::detail::ascii_to_int_impl(sprout::next(str), IntType(), false) : sprout::detail::ascii_to_int_impl(str, IntType(), false) ; diff --git a/sprout/cstdlib/str_to_float.hpp b/sprout/cstdlib/str_to_float.hpp index d09d2760..6a1d2572 100644 --- a/sprout/cstdlib/str_to_float.hpp +++ b/sprout/cstdlib/str_to_float.hpp @@ -19,10 +19,10 @@ namespace sprout { namespace detail { - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_scale( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -45,10 +45,10 @@ namespace sprout { : number ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_exponent_2( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -70,10 +70,10 @@ namespace sprout { : HUGE_VAL ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_exponent_1( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -82,7 +82,7 @@ namespace sprout { long n = 0 ) { - typedef typename std::iterator_traits::value_type char_type; + typedef typename std::iterator_traits::value_type char_type; return sprout::ascii::isdigit(*str) ? sprout::detail::str_to_float_impl_exponent_1( sprout::next(str), negative, @@ -102,10 +102,10 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_exponent( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -113,7 +113,7 @@ namespace sprout { long exponent = 0 ) { - typedef typename std::iterator_traits::value_type char_type; + typedef typename std::iterator_traits::value_type char_type; return (*str == static_cast('e') || *str == static_cast('E')) ? *sprout::next(str) == static_cast('-') ? sprout::detail::str_to_float_impl_exponent_1( @@ -142,10 +142,10 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_decimal_1( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -164,10 +164,10 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl_decimal( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0, @@ -175,7 +175,7 @@ namespace sprout { long exponent = 0 ) { - typedef typename std::iterator_traits::value_type char_type; + typedef typename std::iterator_traits::value_type char_type; return sprout::ascii::isdigit(*str) ? sprout::detail::str_to_float_impl_decimal( sprout::next(str), negative, @@ -195,16 +195,16 @@ namespace sprout { ; } - template + template inline SPROUT_CONSTEXPR FloatType str_to_float_impl( - CStrIterator str, + NullTerminatedIterator str, bool negative, FloatType number = FloatType(), std::size_t num_digits = 0 ) { - typedef typename std::iterator_traits::value_type char_type; + typedef typename std::iterator_traits::value_type char_type; return sprout::ascii::isdigit(*str) ? sprout::detail::str_to_float_impl( sprout::next(str), negative, @@ -225,21 +225,21 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR FloatType - str_to_float(CStrIterator str) { + str_to_float(NullTerminatedIterator str) { return sprout::ascii::isspace(*str) ? sprout::detail::str_to_float(sprout::next(str)) - : *str == static_cast::value_type>('-') + : *str == static_cast::value_type>('-') ? sprout::detail::str_to_float_impl(sprout::next(str), true) - : *str == static_cast::value_type>('+') + : *str == static_cast::value_type>('+') ? sprout::detail::str_to_float_impl(sprout::next(str), false) : sprout::detail::str_to_float_impl(str, false) ; } - template + template inline SPROUT_CONSTEXPR FloatType - str_to_float(CStrIterator str, CharPtr* endptr) { + str_to_float(NullTerminatedIterator str, CharPtr* endptr) { return !endptr ? sprout::detail::str_to_float(str) #if defined(__MINGW32__) : std::is_same::type, float>::value ? ::strtof(&*str, endptr) diff --git a/sprout/cstdlib/str_to_int.hpp b/sprout/cstdlib/str_to_int.hpp index d402c6d3..4c6b44d0 100644 --- a/sprout/cstdlib/str_to_int.hpp +++ b/sprout/cstdlib/str_to_int.hpp @@ -24,9 +24,9 @@ namespace sprout { namespace detail { // Copyright (c) 2011 osyo-manga : http://d.hatena.ne.jp/osyo-manga/ - template + template inline SPROUT_CONSTEXPR IntType - str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) { + str_to_int_impl_1(NullTerminatedIterator str, int base, IntType val, IntType x, bool negative) { return x == static_cast(-1) ? (negative ? -1 * val : val) : val > (sprout::numeric_limits::max() - x - (negative ? 1 : 0)) / base ? (negative ? sprout::numeric_limits::min() : sprout::numeric_limits::max()) @@ -39,12 +39,12 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR IntType - str_to_int_impl(CStrIterator str, int base, bool negative) { - return *str == static_cast::value_type>('0') - ? *sprout::next(str) == static_cast::value_type>('x') - || *sprout::next(str) == static_cast::value_type>('X') + str_to_int_impl(NullTerminatedIterator str, int base, bool negative) { + return *str == static_cast::value_type>('0') + ? *sprout::next(str) == static_cast::value_type>('x') + || *sprout::next(str) == static_cast::value_type>('X') ? sprout::detail::str_to_int_impl_1( sprout::next(str, 2), base ? base : 16, @@ -68,37 +68,37 @@ namespace sprout { ) ; } - template + template inline SPROUT_CONSTEXPR typename std::enable_if< std::is_unsigned::value, IntType >::type - str_to_int(CStrIterator str, int base) { + str_to_int(NullTerminatedIterator str, int base) { return sprout::ascii::isspace(*str) ? sprout::detail::str_to_int(sprout::next(str), base) - : *str == static_cast::value_type>('+') + : *str == static_cast::value_type>('+') ? sprout::detail::str_to_int_impl(sprout::next(str), base, false) : sprout::detail::str_to_int_impl(str, base, false) ; } - template + template inline SPROUT_CONSTEXPR typename std::enable_if< std::is_signed::value, IntType >::type - str_to_int(CStrIterator str, int base) { + str_to_int(NullTerminatedIterator str, int base) { return sprout::ascii::isspace(*str) ? sprout::detail::str_to_int(sprout::next(str), base) - : *str == static_cast::value_type>('-') + : *str == static_cast::value_type>('-') ? sprout::detail::str_to_int_impl(sprout::next(str), base, true) - : *str == static_cast::value_type>('+') + : *str == static_cast::value_type>('+') ? sprout::detail::str_to_int_impl(sprout::next(str), base, false) : sprout::detail::str_to_int_impl(str, base, false) ; } - template + template inline SPROUT_CONSTEXPR IntType - str_to_int(CStrIterator str, CharPtr* endptr, int base) { + str_to_int(NullTerminatedIterator str, CharPtr* endptr, int base) { return !endptr ? sprout::detail::str_to_int(str, base) #if defined(_MSC_VER) : std::is_signed::value diff --git a/sprout/cstring/strcat.hpp b/sprout/cstring/strcat.hpp index 0d51eaf8..ddc045f7 100644 --- a/sprout/cstring/strcat.hpp +++ b/sprout/cstring/strcat.hpp @@ -12,10 +12,10 @@ namespace sprout { namespace detail { - template - inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator - strcat(OutputCStrIterator s1, CStrIterator s2) { - OutputCStrIterator result = s1; + template + inline SPROUT_CXX14_CONSTEXPR OutputNullTerminatedIterator + strcat(OutputNullTerminatedIterator s1, NullTerminatedIterator s2) { + OutputNullTerminatedIterator result = s1; while (*s1++) ; while ((*s1++ = *s2++)) diff --git a/sprout/cstring/strcpy.hpp b/sprout/cstring/strcpy.hpp index 940b7650..c5155cf8 100644 --- a/sprout/cstring/strcpy.hpp +++ b/sprout/cstring/strcpy.hpp @@ -12,10 +12,10 @@ namespace sprout { namespace detail { - template - inline SPROUT_CXX14_CONSTEXPR OutputCStrIterator - strcpy(OutputCStrIterator s1, CStrIterator s2) { - OutputCStrIterator result = s1; + template + inline SPROUT_CXX14_CONSTEXPR OutputNullTerminatedIterator + strcpy(OutputNullTerminatedIterator s1, NullTerminatedIterator s2) { + OutputNullTerminatedIterator result = s1; while ((*s1++ = *s2++)) ; return result; diff --git a/sprout/cstring/strncat.hpp b/sprout/cstring/strncat.hpp index 2aa2c46e..673b6b1b 100644 --- a/sprout/cstring/strncat.hpp +++ b/sprout/cstring/strncat.hpp @@ -13,11 +13,11 @@ 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; + template + inline SPROUT_CXX14_CONSTEXPR OutputNullTerminatedIterator + strncat(OutputNullTerminatedIterator s1, NullTerminatedIterator s2, std::size_t n) { + typedef typename std::iterator_traits::value_type value_type; + OutputNullTerminatedIterator result = s1; while (*s1) { ++s1; } diff --git a/sprout/cstring/strncpy.hpp b/sprout/cstring/strncpy.hpp index 7bbe0914..27893207 100644 --- a/sprout/cstring/strncpy.hpp +++ b/sprout/cstring/strncpy.hpp @@ -13,11 +13,11 @@ 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; + template + inline SPROUT_CXX14_CONSTEXPR OutputNullTerminatedIterator + strncpy(OutputNullTerminatedIterator s1, NullTerminatedIterator s2, std::size_t n) { + typedef typename std::iterator_traits::value_type value_type; + OutputNullTerminatedIterator result = s1; while (n) { --n; if (!(*s1++ = *s2++)) {