2015-07-22 23:37:35 +00:00
|
|
|
/*
|
2020-05-04 01:59:02 +00:00
|
|
|
* Copyright 2015-2020 Michele "King_DuckZ" Santullo
|
2015-07-22 23:37:35 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-03-04 01:19:15 +00:00
|
|
|
#pragma once
|
2015-07-22 23:37:35 +00:00
|
|
|
|
|
|
|
#define define_has_method(method_name,pretty_name) \
|
|
|
|
template <typename T> \
|
|
|
|
struct Has ## pretty_name ## Method { \
|
|
|
|
private: \
|
|
|
|
struct TrueType { int a[2]; }; \
|
|
|
|
typedef int FalseType; \
|
|
|
|
template <typename C> static TrueType has_method ( decltype(&C::method_name) ); \
|
|
|
|
template <typename C> static FalseType has_method ( ... ); \
|
|
|
|
public: \
|
|
|
|
enum { value = sizeof(has_method<T>(0)) == sizeof(TrueType) }; \
|
|
|
|
}
|
|
|
|
#define define_has_typedef(typedef_name,pretty_name) \
|
|
|
|
template <typename T> \
|
|
|
|
struct Has ## pretty_name ## Typedef { \
|
|
|
|
private: \
|
|
|
|
struct TrueType { int a[2]; }; \
|
|
|
|
typedef int FalseType; \
|
2015-07-24 22:55:03 +00:00
|
|
|
template <typename C> static TrueType has_typedef ( const typename C::typedef_name* ); \
|
2015-07-22 23:37:35 +00:00
|
|
|
template <typename C> static FalseType has_typedef ( ... ); \
|
|
|
|
public: \
|
2015-07-24 22:55:03 +00:00
|
|
|
enum { value = sizeof(has_typedef<T>(nullptr)) == sizeof(TrueType) }; \
|
2015-07-22 23:37:35 +00:00
|
|
|
}
|
|
|
|
#define define_has_enum(enum_name,pretty_name) \
|
|
|
|
template <typename T> \
|
|
|
|
struct Has ## pretty_name ## Enum { \
|
|
|
|
private: \
|
|
|
|
struct TrueType { int a[2]; }; \
|
|
|
|
typedef int FalseType; \
|
2015-07-24 22:55:03 +00:00
|
|
|
template <typename C> static TrueType has_enum ( decltype(C::enum_name)* ); \
|
2015-07-22 23:37:35 +00:00
|
|
|
template <typename C> static FalseType has_enum ( ... ); \
|
|
|
|
public:\
|
2015-07-23 21:09:35 +00:00
|
|
|
enum { value = sizeof(has_enum<T>(nullptr)) == sizeof(TrueType) }; \
|
2015-07-22 23:37:35 +00:00
|
|
|
}
|