Skip to content

Commit

Permalink
Cleanup ZNC_LVREFQUAL
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthGandalf committed Nov 18, 2023
1 parent 157095f commit 0a35563
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions include/znc/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
#ifndef ZNC_MESSAGE_H
#define ZNC_MESSAGE_H

// Remove this after Feb 2016 when Debian 7 is EOL
#if __cpp_ref_qualifiers >= 200710
#define ZNC_LVREFQUAL &
#elif defined(__clang__)
#define ZNC_LVREFQUAL &
#elif __GNUC__ > 4 || \
__GNUC__ == 4 && (__GNUC_MINOR__ > 8 || \
__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ >= 1)
#define ZNC_LVREFQUAL &
#else
#define ZNC_LVREFQUAL
#endif

#ifdef SWIG
#define ZNC_MSG_DEPRECATED(msg)
#else
Expand Down Expand Up @@ -166,7 +153,7 @@ class CMessage {
// Implicit and explicit conversion to a subclass reference.
#ifndef SWIG
template <typename M>
M& As() ZNC_LVREFQUAL {
M& As() & {
static_assert(std::is_base_of<CMessage, M>{},
"Must be subclass of CMessage");
static_assert(sizeof(M) == sizeof(CMessage),
Expand All @@ -175,7 +162,7 @@ class CMessage {
}

template <typename M>
const M& As() const ZNC_LVREFQUAL {
const M& As() const& {
static_assert(std::is_base_of<CMessage, M>{},
"Must be subclass of CMessage");
static_assert(sizeof(M) == sizeof(CMessage),
Expand All @@ -185,12 +172,12 @@ class CMessage {

template <typename M, typename = typename std::enable_if<
std::is_base_of<CMessage, M>{}>::type>
operator M&() ZNC_LVREFQUAL {
operator M&() & {
return As<M>();
}
template <typename M, typename = typename std::enable_if<
std::is_base_of<CMessage, M>{}>::type>
operator const M&() const ZNC_LVREFQUAL {
operator const M&() const& {
return As<M>();
}
// REGISTER_ZNC_MESSAGE allows SWIG to instantiate correct .As<> calls.
Expand Down

0 comments on commit 0a35563

Please sign in to comment.