summaryrefslogtreecommitdiff
path: root/boost/sort/spreadsort/spreadsort.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/sort/spreadsort/spreadsort.hpp')
-rw-r--r--boost/sort/spreadsort/spreadsort.hpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/boost/sort/spreadsort/spreadsort.hpp b/boost/sort/spreadsort/spreadsort.hpp
index 678fba44f1..48377123e3 100644
--- a/boost/sort/spreadsort/spreadsort.hpp
+++ b/boost/sort/spreadsort/spreadsort.hpp
@@ -88,8 +88,8 @@ namespace spreadsort {
}
/*!
- \brief Generic @c spreadsort variant detecting string element type so call to @c string_sort for @c std::strings and @c std::wstrings.
- \details If the data type provided is a string or wstring, @c string_sort is used.
+ \brief Generic @c spreadsort variant detecting string element type so call to @c string_sort for @c std::strings.
+ \details If the data type provided is a string, @c string_sort is used.
\note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly,
as @c spreadsort won't accept types that don't have the appropriate @c type_traits.
@@ -107,13 +107,38 @@ namespace spreadsort {
template <class RandomAccessIter>
inline typename boost::enable_if_c<
is_same<typename std::iterator_traits<RandomAccessIter>::value_type,
- typename std::string>::value ||
- is_same<typename std::iterator_traits<RandomAccessIter>::value_type,
- typename std::wstring>::value, void >::type
+ typename std::string>::value, void >::type
spreadsort(RandomAccessIter first, RandomAccessIter last)
{
string_sort(first, last);
}
+
+ /*!
+ \brief Generic @c spreadsort variant detecting string element type so call to @c string_sort for @c std::wstrings.
+ \details If the data type provided is a wstring, @c string_sort is used.
+ \note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly,
+ as @c spreadsort won't accept types that don't have the appropriate @c type_traits. Also, 2-byte wide-characters are the limit above which string_sort is inefficient, so on platforms with wider characters, this will not accept wstrings.
+
+ \param[in] first Iterator pointer to first element.
+ \param[in] last Iterator pointing to one beyond the end of data.
+
+ \pre [@c first, @c last) is a valid range.
+ \pre @c RandomAccessIter @c value_type is mutable.
+ \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a>
+ \pre @c RandomAccessIter @c value_type supports the @c operator>>,
+ which returns an integer-type right-shifted a specified number of bits.
+ \post The elements in the range [@c first, @c last) are sorted in ascending order.
+ */
+ template <class RandomAccessIter>
+ inline typename boost::enable_if_c<
+ is_same<typename std::iterator_traits<RandomAccessIter>::value_type,
+ typename std::wstring>::value &&
+ sizeof(wchar_t) == 2, void >::type
+ spreadsort(RandomAccessIter first, RandomAccessIter last)
+ {
+ boost::uint16_t unused = 0;
+ string_sort(first, last, unused);
+ }
} // namespace spreadsort
} // namespace sort
} // namespace boost