Table Of Contents

Previous topic

lt

Next topic

length

This Page

compare

Interface

static SPROUT_CONSTEXPR int compare(char_type const* s1, char_type const* s2, std::size_t n);

Returns

Equivalent to std::char_traits<Char>::compare(s1, s2, n) in constant expression.

Examples

#include <sprout/string.hpp>
using namespace sprout;

SPROUT_STATIC_CONSTEXPR char const* x = "homuhomu";
SPROUT_STATIC_CONSTEXPR char const* y = "madocchi";
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::compare(x, y, 8);
static_assert(result < 0, "x is less than y.");

Complexity

linear.
Recursive function invocations in O(logN) (logarithmic) depth.