view: remove implicit equality for strings
This commit is contained in:
parent
b99db1a893
commit
9031a12890
10
cpp.cpp
10
cpp.cpp
@ -66,11 +66,11 @@ processor::process (
|
||||
auto head = tokens.begin ();
|
||||
auto head_string = std::string { head->begin () + 1, head->size () - 1 };
|
||||
|
||||
if (*head == "#endif")
|
||||
if (equal (*head, "#endif"))
|
||||
return l;
|
||||
|
||||
|
||||
if (*head == "#define") {
|
||||
if (equal (*head, "#define")) {
|
||||
auto key = head;
|
||||
++key;
|
||||
|
||||
@ -85,7 +85,7 @@ processor::process (
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*head == "#ifndef") {
|
||||
if (equal (*head, "#ifndef")) {
|
||||
auto tail = head + 1;
|
||||
if (tail == tokens.end ())
|
||||
throw std::runtime_error ("expected token for define");
|
||||
@ -96,12 +96,12 @@ processor::process (
|
||||
l = process (os, ctx, {++l, lines.end ()});
|
||||
// ... or skip until and endif
|
||||
} else {
|
||||
for (++l; l != lines.end () && *l != "#endif"; ++l)
|
||||
for (++l; l != lines.end () && !equal (*l, "#endif"); ++l)
|
||||
;
|
||||
}
|
||||
|
||||
// check if we've got the expected endif
|
||||
if (l == lines.cend () || *l != "#endif")
|
||||
if (l == lines.cend () || !equal (*l, "#endif"))
|
||||
throw std::runtime_error ("expected #endif");
|
||||
|
||||
continue;
|
||||
|
18
view.hpp
18
view.hpp
@ -921,24 +921,6 @@ namespace cruft {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename CharT>
|
||||
bool
|
||||
operator== (
|
||||
view<const CharT*> lhs,
|
||||
const std::basic_string<CharT> &rhs
|
||||
) {
|
||||
return lhs.size () == rhs.size () && std::equal (lhs.cbegin (), lhs.cend (), rhs.cbegin ());
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator== (view<const char*> lhs, const char *rhs)
|
||||
{
|
||||
return lhs.size () == strlen (rhs) && std::equal (lhs.cbegin (), lhs.cend (), rhs);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename BeginT, typename EndT>
|
||||
std::ostream&
|
||||
|
Loading…
Reference in New Issue
Block a user