The following code prints 1010
#include <iostream>
#include <range/v3/algorithm/starts_with.hpp>
int main () {
using namespace std::literals;
std::cout << ranges::starts_with("hello world"s, "hello"s)
<< ranges::starts_with("hello world"s, "hello")
<< ranges::starts_with("hello world", "hello"s)
<< ranges::starts_with("hello world", "hello") << std::endl; // prints 1010
}
Why is that?
I've also noticed that if the two stings are the same, then also the last case returns 1
:
std::cout << ranges::starts_with("hello world"s, "hello world"s)
<< ranges::starts_with("hello world"s, "hello world")
<< ranges::starts_with("hello world", "hello world"s)
<< ranges::starts_with("hello world", "hello world") << std::endl; // prints 1011
I know that a std::string
, such as "bla"s
, is a range, and that a char[N]
is a range too, given a constant N
. So I don't see why