CharReach operators inline

This commit is contained in:
Alex Coyte 2016-04-11 13:47:10 +10:00 committed by Matthew Barr
parent ff721ed8e4
commit 938ac9fd38
2 changed files with 24 additions and 46 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Intel Corporation * Copyright (c) 2015-2016, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -50,44 +50,6 @@ void CharReach::set(const std::string &s) {
} }
} }
/// Bitwise OR.
CharReach CharReach::operator|(const CharReach &a) const {
CharReach cr(*this);
cr.bits |= a.bits;
return cr;
}
/// Bitwise OR-equals.
void CharReach::operator|=(const CharReach &a) {
bits |= a.bits;
}
/// Bitwise AND.
CharReach CharReach::operator&(const CharReach &a) const {
CharReach cr(*this);
cr.bits &= a.bits;
return cr;
}
/// Bitwise AND-equals.
void CharReach::operator&=(const CharReach &a) {
bits &= a.bits;
}
/// Bitwise complement.
CharReach CharReach::operator~(void) const {
CharReach cr(*this);
cr.flip();
return cr;
}
/// Bitwise XOR.
CharReach CharReach::operator^(const CharReach &a) const {
CharReach cr(*this);
cr.bits ^= a.bits;
return cr;
}
/// Do we only contain bits representing alpha characters? /// Do we only contain bits representing alpha characters?
bool CharReach::isAlpha() const { bool CharReach::isAlpha() const {
if (none()) { if (none()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Intel Corporation * Copyright (c) 2015-2016, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -135,22 +135,38 @@ public:
size_t find_nth(size_t n) const { return bits.find_nth(n); } size_t find_nth(size_t n) const { return bits.find_nth(n); }
/// Bitwise OR. /// Bitwise OR.
CharReach operator|(const CharReach &a) const; CharReach operator|(const CharReach &a) const {
CharReach cr(*this);
cr.bits |= a.bits;
return cr;
}
/// Bitwise OR-equals. /// Bitwise OR-equals.
void operator|=(const CharReach &a); void operator|=(const CharReach &a) { bits |= a.bits; }
/// Bitwise AND. /// Bitwise AND.
CharReach operator&(const CharReach &a) const; CharReach operator&(const CharReach &a) const {
CharReach cr(*this);
cr.bits &= a.bits;
return cr;
}
/// Bitwise AND-equals. /// Bitwise AND-equals.
void operator&=(const CharReach &a); void operator&=(const CharReach &a) { bits &= a.bits; }
/// Bitwise XOR. /// Bitwise XOR.
CharReach operator^(const CharReach &a) const; CharReach operator^(const CharReach &a) const {
CharReach cr(*this);
cr.bits ^= a.bits;
return cr;
}
/// Bitwise complement. /// Bitwise complement.
CharReach operator~(void) const; CharReach operator~(void) const {
CharReach cr(*this);
cr.flip();
return cr;
}
/// Do we only contain bits representing alpha characters? /// Do we only contain bits representing alpha characters?
bool isAlpha() const; bool isAlpha() const;