mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add <cstring> and <cwchar> compatible constexpr functions
This commit is contained in:
parent
fe255a5e74
commit
b04dea6002
26 changed files with 526 additions and 103 deletions
24
sprout/cwchar/wcscat.hpp
Normal file
24
sprout/cwchar/wcscat.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/strcat.hpp>
|
||||
|
||||
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
|
24
sprout/cwchar/wcscpy.hpp
Normal file
24
sprout/cwchar/wcscpy.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/strcpy.hpp>
|
||||
|
||||
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
|
24
sprout/cwchar/wcsncat.hpp
Normal file
24
sprout/cwchar/wcsncat.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/strncat.hpp>
|
||||
|
||||
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
|
24
sprout/cwchar/wcsncpy.hpp
Normal file
24
sprout/cwchar/wcsncpy.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/strncpy.hpp>
|
||||
|
||||
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
|
|
@ -8,27 +8,10 @@
|
|||
#ifndef SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
#define SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/ptr_index_iterator.hpp>
|
||||
#include <sprout/algorithm/find.hpp>
|
||||
#include <sprout/cstring/memchr.hpp>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
#ifndef SPROUT_CWCHAR_WMEMCMP_HPP
|
||||
#define SPROUT_CWCHAR_WMEMCMP_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/ptr_index_iterator.hpp>
|
||||
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
|
||||
#include <sprout/cstring/memcmp.hpp>
|
||||
|
||||
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
|
||||
|
||||
|
|
24
sprout/cwchar/wmemcpy.hpp
Normal file
24
sprout/cwchar/wmemcpy.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/memcpy.hpp>
|
||||
|
||||
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
|
24
sprout/cwchar/wmemmove.hpp
Normal file
24
sprout/cwchar/wmemmove.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/memmove.hpp>
|
||||
|
||||
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
|
24
sprout/cwchar/wmemset.hpp
Normal file
24
sprout/cwchar/wmemset.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/cstring/memset.hpp>
|
||||
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue