Skip to content

Commit

Permalink
src/Common/object_type_traits.h: Some templates reimplemented via stl.
Browse files Browse the repository at this point in the history
Fixed compilation with gcc.
  • Loading branch information
Kaffeine committed Dec 2, 2015
1 parent 799cef6 commit 7efe143
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions src/Common/object_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define object_type_traits_h_included
#pragma once

#include <type_traits>

//#define USE_BOOST

#ifdef USE_BOOST
Expand All @@ -28,32 +30,12 @@

template <bool expression, typename T1, typename T2>
struct _if {
template <bool>
struct selector {
typedef T2 result;
};

template <>
struct selector<true> {
typedef T1 result;
};

typedef typename selector<expression>::result result;
using result = typename std::conditional<expression, T1, T2>::type;
};

template <typename T1, typename T2>
struct is_type {
template <typename T>
struct selector {
enum { value = false, };
};

template <>
struct selector<T1> {
enum { value = true, };
};

enum { value = selector<T2>::value, };
enum { value = std::is_same<T1,T2>::value, };
};

template <typename T>
Expand Down Expand Up @@ -102,13 +84,7 @@

template <typename T>
struct is_void {
template <typename P>
struct select {enum { value = false}; };

template <>
struct select<void> {enum { value = true}; };

enum { value = select<T>::value};
enum { value = std::is_same<void,T>::value };
};

template <typename T> struct is_const{
Expand Down

0 comments on commit 7efe143

Please sign in to comment.