8namespace System {
namespace detail {
13template <class From, class To, class = decltype(static_cast<To*>((From*)
nullptr))>
18template <
class From,
class To>
25template <
class From,
class To>
32template <typename From, typename To, bool convertible = is_static_castable<From, To>::value>
38 static To*
cast(From *pointer) {
return dynamic_cast<To*
>(pointer); }
45template <
typename From,
typename To>
51 static To*
cast(From *pointer) {
return static_cast<To*
>(pointer); }
58template <
template <
class ...T>
class TypeToBe>
65 template <
typename ...P>
66 static std::true_type
Invoke(
const TypeToBe<P...>*);
70 template <
typename Tested>
71 using type =
decltype(Invoke((Tested*)
nullptr));
79template <
typename Tested,
template <
class ...T>
class TypeToBe>
82template <
typename Tested,
template <
class ...T>
class TypeToBe>
85template <
typename Tested,
template <
class ...T>
class TypeToBe>
94template<
typename T,
typename Sfinae =
void>
100 , decltype((void)(std::declval<T&>() < std::declval<T&>()))
110 static auto test(U*) ->
decltype(std::declval<U>() == std::declval<U>());
112 static auto test(...) -> std::false_type;
114 using type =
typename std::is_same<bool, decltype(test<T>(0))>
::type;
128template <
class T,
class U>
129struct has_no_operator_equal : std::integral_constant<bool, !has_operator_equal<T>::value && !has_operator_equal<U>::value> {};
136template<
typename T,
typename Sfinae =
void>
142 , decltype((void)(std::declval<T&>().
Equals(std::declval<T&>())))
158template<
typename T,
typename Sfinae =
void>
164 , decltype((void)(std::declval<T&>().
GetHashCode()))
165> : std::true_type {};
173template<
typename T,
typename Sfinae =
void>
179 , decltype((void)(std::declval<T&>()->
GetHashCode()))
180> : std::true_type {};
188template<
typename T,
typename Sfinae =
void>
194 , decltype((void)(std::declval<T&>().CompareTo(*static_cast<T*>(nullptr))))
195> : std::true_type {};
203template<
typename T,
typename Sfinae =
void>
209 , decltype((void)(std::declval<T&>()->CompareTo(*static_cast<T*>(nullptr))))
210> : std::true_type {};
217template<
typename T,
typename Sfinae =
void>
223 , decltype((void)(std::declval<T&>()->get_Count()))
224> : std::true_type {};
231template<
typename T,
typename Sfinae =
void>
237 , decltype((void)(
PrintTo(std::declval<T&>(), std::declval<std::ostream*>())))
245template<
typename T,
typename Sfinae =
void>
251 , decltype((void)(std::declval<T&>().IsNull()))
252> : std::true_type {};
258template <
typename from,
typename to>
std::true_type IsStaticCastable_Internal(int)
SFINAE to check if static_cast works between two types.
decltype(IsStaticCastable_Internal< From, To >(0)) is_static_castable
Checks if static_cast works between two types. If possible, typedefs std::true_type,...
Definition: detail.h:26
std::integral_constant< bool, has_method_equals< T >::value &&!has_operator_equal< T >::value > has_only_method_equals
Checks whether specific type has Equals method but not operator ==. If so, value member is true,...
Definition: detail.h:150
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
std::enable_if< std::is_scalar< T >::value, int >::type GetHashCode(const T &obj)
Returns a hash code for the specified scalar value.
Definition: get_hash_code.h:21
Helper class to check if specific type is a specialization of a given template.
Definition: detail.h:60
static std::true_type Invoke(const TypeToBe< P... > *)
Detects that pointee is a template specialization.
static std::false_type Invoke(...)
Detects that pointee is not a template specialization.
decltype(Invoke((Tested *) nullptr)) type
If Tested is a specialization of TypeToBe, typedefs std::true_type, otherwise typedefs std::false_typ...
Definition: detail.h:71
static To * cast(From *pointer)
Performs actual pointer casting using static_cast.
Definition: detail.h:51
Performs cheapest cast possible from static_cast and dynamic_cast.
Definition: detail.h:34
static To * cast(From *pointer)
Performs actual pointer casting using dynamic_cast.
Definition: detail.h:38
Checks whether CompareTo method exists in the specified type returned by operator ->....
Definition: detail.h:204
Checks whether CompareTo method exists in the specified type. If so, inherits std::true_type,...
Definition: detail.h:189
Checks whether Equals method exists in specified type. If so, inherits std::true_type,...
Definition: detail.h:137
Checks whether get_Count method exists. If so, inherits std::true_type, otherwise inherits std::false...
Definition: detail.h:218
Checks whether GetHashCode method exists in specified type. If so, inherits std::true_type,...
Definition: detail.h:159
Checks whether IsNull method exists. If so, inherits std::true_type, otherwise inherits std::false_ty...
Definition: detail.h:246
Checks whether operator == not defined neither for T, not for U types. Can be used in std::enable_if.
Definition: detail.h:129
Implementation for has_operator_equal.
Definition: detail.h:108
typename std::is_same< bool, decltype(test< T >(0))>::type type
Definition: detail.h:114
static auto test(...) -> std::false_type
static auto test(U *) -> decltype(std::declval< U >()==std::declval< U >())
Checks whether operator == exists in specified type. If so, inherits std::true_type,...
Definition: detail.h:122
Checks whether operator < exists in specified type. If so, inherits std::true_type,...
Definition: detail.h:95
Checks whether PrintTo function exists for specified type. If so, inherits std::true_type,...
Definition: detail.h:232
Checks whether GetHashCode method exists in type returned by specified type's operator ->....
Definition: detail.h:174
Tests if specific type is a specialization of specific template. If it is, inherits std::true_type,...
Definition: detail.h:80
Checks if pointers are implicitly convertible. Workaround for VS implementation of std::is_convertibl...
Definition: detail.h:260
static std::true_type check(to *)
SFINAE stub for possible conversions.
static std::false_type check(...)
SFINAE stub for impossible conversions.
decltype(check(std::declval< from * >())) type
Either true_type or false_type, defining whether the implicit conversion is possible.
Definition: detail.h:266