From 938ac9fd38e4122244bfb945f1a04e821f5c7383 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Mon, 11 Apr 2016 13:47:10 +1000 Subject: [PATCH] CharReach operators inline --- src/util/charreach.cpp | 40 +--------------------------------------- src/util/charreach.h | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/src/util/charreach.cpp b/src/util/charreach.cpp index a231bbb0..9116b719 100644 --- a/src/util/charreach.cpp +++ b/src/util/charreach.cpp @@ -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 * 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? bool CharReach::isAlpha() const { if (none()) { diff --git a/src/util/charreach.h b/src/util/charreach.h index 64bd969e..53f2a5d2 100644 --- a/src/util/charreach.h +++ b/src/util/charreach.h @@ -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 * 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); } /// 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. - void operator|=(const CharReach &a); + void operator|=(const CharReach &a) { bits |= a.bits; } /// 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. - void operator&=(const CharReach &a); + void operator&=(const CharReach &a) { bits &= a.bits; } /// 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. - CharReach operator~(void) const; + CharReach operator~(void) const { + CharReach cr(*this); + cr.flip(); + return cr; + } /// Do we only contain bits representing alpha characters? bool isAlpha() const;