utf8: replace InvalidBytePolicy::Throw with InvalidBytePolicy::Assert

This commit is contained in:
Maxime Coste 2012-10-17 17:01:51 +02:00
parent c1387dc592
commit df400f90ab
2 changed files with 5 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include <cstddef>
#include "unicode.hh"
#include "assert.hh"
namespace Kakoune
{
@ -79,14 +80,12 @@ bool is_character_start(Iterator it)
return (*it & 0xC0) != 0x80;
}
struct invalid_utf8_sequence{};
namespace InvalidBytePolicy
{
struct Throw
struct Assert
{
Codepoint operator()(char byte) const { throw invalid_utf8_sequence{}; }
Codepoint operator()(char byte) const { assert(false); return byte; }
};
struct Pass
@ -98,7 +97,7 @@ struct Pass
// returns the codepoint of the character whose first byte
// is pointed by it
template<typename InvalidPolicy = InvalidBytePolicy::Throw,
template<typename InvalidPolicy = InvalidBytePolicy::Assert,
typename Iterator>
Codepoint codepoint(Iterator it)
{

View File

@ -12,7 +12,7 @@ namespace utf8
// adapter for an iterator on bytes which permits to iterate
// on unicode codepoints instead.
template<typename Iterator,
typename InvalidPolicy = InvalidBytePolicy::Throw>
typename InvalidPolicy = InvalidBytePolicy::Assert>
class utf8_iterator
{
public: