mercredi 4 novembre 2015

find if string starts with sub string using std::equal

May you please point me to what is the wrong thing I am doing here?

auto is_start_with = [](std::string const& whole_string, std::string const& starting_substring)->bool{
        if (starting_substring.size() > whole_string.size()) return false;
        return std::equal(begin(starting_substring), end(starting_substring), begin(whole_string));
    };

It is always return true.

I know there is many many other solutions but I want to know what is the error here.

Aucun commentaire:

Enregistrer un commentaire