common: Work around SFINAE issues in MSVC
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Oct 2016 17:42:38 +0000 (19:42 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 4 Apr 2018 21:14:03 +0000 (23:14 +0200)
MSVC 2015 still has... issues with SFINAE, so the usual way to use
std::enable_if doesn't compile. So let's try and SFINAE this in a
different way until MS fixes their compiler.

(cherry picked from commit bfa14a673eabd3a3f17d68843a634703c821df9c)

src/common/types.h

index 81c5715..a801de7 100644 (file)
@@ -115,7 +115,7 @@ typedef QList<BufferId> BufferIdList;
  * @returns A reference to the stream
  */
 template<typename T,
-         typename std::enable_if<std::is_enum<T>{}, int>::type = 0>
+         typename = typename std::enable_if<std::is_enum<T>::value>::type>
 QDataStream &operator<<(QDataStream &out, T value) {
     out << static_cast<typename std::underlying_type<T>::type>(value);
     return out;
@@ -129,7 +129,7 @@ QDataStream &operator<<(QDataStream &out, T value) {
  * @returns A reference to the stream
  */
 template<typename T,
-         typename std::enable_if<std::is_enum<T>{}, int>::type = 0>
+         typename = typename std::enable_if<std::is_enum<T>::value>::type>
 QDataStream &operator>>(QDataStream &in, T &value) {
     typename std::underlying_type<T>::type v;
     in >> v;