diff options
Diffstat (limited to 'googlemock/include/gmock/internal/gmock-internal-utils.h')
-rw-r--r-- | googlemock/include/gmock/internal/gmock-internal-utils.h | 75 |
1 files changed, 16 insertions, 59 deletions
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 8424908..1770d5e 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -106,25 +106,6 @@ inline Element* GetRawPointer(Element* p) { return p; } # define GMOCK_WCHAR_T_IS_NATIVE_ 1 #endif -// signed wchar_t and unsigned wchar_t are NOT in the C++ standard. -// Using them is a bad practice and not portable. So DON'T use them. -// -// Still, Google Mock is designed to work even if the user uses signed -// wchar_t or unsigned wchar_t (obviously, assuming the compiler -// supports them). -// -// To gcc, -// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int -// -// gcc-9 appears to treat signed/unsigned wchar_t as ill-formed -// regardless of the signage of its underlying type. -#ifdef __GNUC__ -#if !defined(__WCHAR_UNSIGNED__) && (__GNUC__ < 9) -// signed/unsigned wchar_t are valid types. -# define GMOCK_HAS_SIGNED_WCHAR_T_ 1 -#endif -#endif - // In what follows, we use the term "kind" to indicate whether a type // is bool, an integer type (excluding bool), a floating-point type, // or none of them. This categorization is useful for determining @@ -189,27 +170,27 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint); // From, and kToKind is the kind of To; the value is // implementation-defined when the above pre-condition is violated. template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To> -struct LosslessArithmeticConvertibleImpl : public false_type {}; +struct LosslessArithmeticConvertibleImpl : public std::false_type {}; // Converting bool to bool is lossless. template <> struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool> - : public true_type {}; // NOLINT + : public std::true_type {}; // Converting bool to any integer type is lossless. template <typename To> struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To> - : public true_type {}; // NOLINT + : public std::true_type {}; // Converting bool to any floating-point type is lossless. template <typename To> struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To> - : public true_type {}; // NOLINT + : public std::true_type {}; // Converting an integer to bool is lossy. template <typename From> struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool> - : public false_type {}; // NOLINT + : public std::false_type {}; // Converting an integer to another non-bool integer is lossless if // the target type's range encloses the source type's range. @@ -230,17 +211,17 @@ struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To> // the format of a floating-point number is implementation-defined. template <typename From, typename To> struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To> - : public false_type {}; // NOLINT + : public std::false_type {}; // Converting a floating-point to bool is lossy. template <typename From> struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool> - : public false_type {}; // NOLINT + : public std::false_type {}; // Converting a floating-point to an integer is lossy. template <typename From, typename To> struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To> - : public false_type {}; // NOLINT + : public std::false_type {}; // Converting a floating-point to another floating-point is lossless // if the target type is at least as big as the source type. @@ -355,14 +336,6 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); // Type traits. -// is_reference<T>::value is non-zero if T is a reference type. -template <typename T> struct is_reference : public false_type {}; -template <typename T> struct is_reference<T&> : public true_type {}; - -// type_equals<T1, T2>::value is non-zero if T1 and T2 are the same type. -template <typename T1, typename T2> struct type_equals : public false_type {}; -template <typename T> struct type_equals<T, T> : public true_type {}; - // remove_reference<T>::type removes the reference from type T, if any. template <typename T> struct remove_reference { typedef T type; }; // NOLINT template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT @@ -416,8 +389,8 @@ class StlContainerView { static const_reference ConstReference(const RawContainer& container) { // Ensures that RawContainer is not a const type. - testing::StaticAssertTypeEq<RawContainer, - GTEST_REMOVE_CONST_(RawContainer)>(); + testing::StaticAssertTypeEq< + RawContainer, typename std::remove_const<RawContainer>::type>(); return container; } static type Copy(const RawContainer& container) { return container; } @@ -427,7 +400,7 @@ class StlContainerView { template <typename Element, size_t N> class StlContainerView<Element[N]> { public: - typedef GTEST_REMOVE_CONST_(Element) RawElement; + typedef typename std::remove_const<Element>::type RawElement; typedef internal::NativeArray<RawElement> type; // NativeArray<T> can represent a native array either by value or by // reference (selected by a constructor argument), so 'const type' @@ -451,8 +424,8 @@ class StlContainerView<Element[N]> { template <typename ElementPointer, typename Size> class StlContainerView< ::std::tuple<ElementPointer, Size> > { public: - typedef GTEST_REMOVE_CONST_( - typename internal::PointeeOf<ElementPointer>::type) RawElement; + typedef typename std::remove_const< + typename internal::PointeeOf<ElementPointer>::type>::type RawElement; typedef internal::NativeArray<RawElement> type; typedef const type const_reference; @@ -484,28 +457,12 @@ struct RemoveConstFromKey<std::pair<const K, V> > { typedef std::pair<K, V> type; }; -// Mapping from booleans to types. Similar to boost::bool_<kValue> and -// std::integral_constant<bool, kValue>. -template <bool kValue> -struct BooleanConstant {}; - // Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to // reduce code size. GTEST_API_ void IllegalDoDefault(const char* file, int line); -// Helper types for Apply() below. -template <size_t... Is> struct int_pack { typedef int_pack type; }; - -template <class Pack, size_t I> struct append; -template <size_t... Is, size_t I> -struct append<int_pack<Is...>, I> : int_pack<Is..., I> {}; - -template <size_t C> -struct make_int_pack : append<typename make_int_pack<C - 1>::type, C - 1> {}; -template <> struct make_int_pack<0> : int_pack<> {}; - template <typename F, typename Tuple, size_t... Idx> -auto ApplyImpl(F&& f, Tuple&& args, int_pack<Idx...>) -> decltype( +auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype( std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) { return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...); } @@ -514,9 +471,9 @@ auto ApplyImpl(F&& f, Tuple&& args, int_pack<Idx...>) -> decltype( template <typename F, typename Tuple> auto Apply(F&& f, Tuple&& args) -> decltype(ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), - make_int_pack<std::tuple_size<Tuple>::value>())) { + MakeIndexSequence<std::tuple_size<Tuple>::value>())) { return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), - make_int_pack<std::tuple_size<Tuple>::value>()); + MakeIndexSequence<std::tuple_size<Tuple>::value>()); } // Template struct Function<F>, where F must be a function type, contains |