Skip to content

Commit 260982e

Browse files
authored
Merge pull request #207 from boostorg/update_concepts
Update concepts to check for accidental char_traits usage.
2 parents b130106 + 6efa868 commit 260982e

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

include/boost/regex/concepts.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,10 @@ inline long hash_value(char_architype val)
7676
//
7777
} // namespace boost
7878
namespace std{
79-
template<> struct char_traits<boost::char_architype>
80-
{
81-
// The intent is that this template is not instantiated,
82-
// but this typedef gives us a chance of compilation in
83-
// case it is:
84-
typedef boost::char_architype char_type;
85-
};
79+
//
80+
// We should never use this, if we do it should be an error:
81+
//
82+
template<> struct char_traits<boost::char_architype>;
8683
}
8784
//
8885
// Allocator architype:
@@ -412,6 +409,10 @@ struct BaseRegexConcept
412409
Regex e5(in1, in2, m_flags);
413410
ignore_unused_variable_warning(e5);
414411

412+
// equals:
413+
e1 == e2;
414+
e1 != e2;
415+
415416
// assign etc:
416417
Regex e;
417418
e = m_pointer;

include/boost/regex/v5/basic_regex.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,21 @@ class basic_regex : public regbase
533533
return status() - that.status();
534534
if(flags() != that.flags())
535535
return flags() - that.flags();
536-
return str().compare(that.str());
536+
537+
const char_type* i = m_pimpl->begin();
538+
const char_type* j = that.m_pimpl->begin();
539+
while ((i != m_pimpl->end()) && (j != that.m_pimpl->end()))
540+
{
541+
if (*i != *j)
542+
return *i < *j ? -1 : 1;
543+
++i;
544+
++j;
545+
}
546+
if (i != m_pimpl->end())
547+
return *i > static_cast<char_type>(0) ? 1 : -1;
548+
if (j != that.m_pimpl->end())
549+
return *j > static_cast<char_type>(0) ? -1 : 1;
550+
return 0;
537551
}
538552
bool operator==(const basic_regex& e)const
539553
{

0 commit comments

Comments
 (0)