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>
Thu, 6 Oct 2016 17:42:38 +0000 (19:42 +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.

src/common/types.h

index 34a5fb1..eb0c0ca 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;