Skip to content

Commit

Permalink
Merge pull request #207 from boostorg/update_concepts
Browse files Browse the repository at this point in the history
Update concepts to check for accidental char_traits usage.
  • Loading branch information
jzmaddock authored Mar 25, 2024
2 parents b130106 + 6efa868 commit 260982e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
15 changes: 8 additions & 7 deletions include/boost/regex/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ inline long hash_value(char_architype val)
//
} // namespace boost
namespace std{
template<> struct char_traits<boost::char_architype>
{
// The intent is that this template is not instantiated,
// but this typedef gives us a chance of compilation in
// case it is:
typedef boost::char_architype char_type;
};
//
// We should never use this, if we do it should be an error:
//
template<> struct char_traits<boost::char_architype>;
}
//
// Allocator architype:
Expand Down Expand Up @@ -412,6 +409,10 @@ struct BaseRegexConcept
Regex e5(in1, in2, m_flags);
ignore_unused_variable_warning(e5);

// equals:
e1 == e2;
e1 != e2;

// assign etc:
Regex e;
e = m_pointer;
Expand Down
16 changes: 15 additions & 1 deletion include/boost/regex/v5/basic_regex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,21 @@ class basic_regex : public regbase
return status() - that.status();
if(flags() != that.flags())
return flags() - that.flags();
return str().compare(that.str());

const char_type* i = m_pimpl->begin();
const char_type* j = that.m_pimpl->begin();
while ((i != m_pimpl->end()) && (j != that.m_pimpl->end()))
{
if (*i != *j)
return *i < *j ? -1 : 1;
++i;
++j;
}
if (i != m_pimpl->end())
return *i > static_cast<char_type>(0) ? 1 : -1;
if (j != that.m_pimpl->end())
return *j > static_cast<char_type>(0) ? -1 : 1;
return 0;
}
bool operator==(const basic_regex& e)const
{
Expand Down

0 comments on commit 260982e

Please sign in to comment.