Skip to content

Commit

Permalink
Disable deprecations when specializing templates and template variabl…
Browse files Browse the repository at this point in the history
…es using deprecated templates to fix gcc deprecation warnings.
  • Loading branch information
grojo-ea committed Aug 18, 2024
1 parent 4b788cd commit 9ea79f7
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ target_include_directories(EASTL PUBLIC include)
FetchContent_Declare(
EABase
GIT_REPOSITORY https://github.com/electronicarts/EABase.git
GIT_TAG c11d898e3d175c9e957df86e4afe5403429f57f1
GIT_TAG 123363eb82e132c0181ac53e43226d8ee76dea12
GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EABase.
)

Expand Down
9 changes: 0 additions & 9 deletions benchmark/source/BenchmarkDeque.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ namespace
}


EASTL_DECLARE_POD(ValuePair)
EASTL_DECLARE_TRIVIAL_CONSTRUCTOR(ValuePair)
EASTL_DECLARE_TRIVIAL_COPY(ValuePair)
EASTL_DECLARE_TRIVIAL_ASSIGN(ValuePair)
EASTL_DECLARE_TRIVIAL_DESTRUCTOR(ValuePair)
EASTL_DECLARE_TRIVIAL_RELOCATE(ValuePair)



typedef std::deque<ValuePair> StdDeque;
typedef eastl::deque<ValuePair, EASTLAllocatorType, 128> EaDeque; // What value do we pick for the subarray size to make the comparison fair? Using the default isn't ideal because it results in this test measuring speed efficiency and ignoring memory efficiency.

Expand Down
4 changes: 4 additions & 0 deletions include/EASTL/internal/functional_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ namespace eastl

/// bind1st
///
EASTL_INTERNAL_DISABLE_DEPRECATED() // unariy_function is deprecated
template <typename Operation>
class EASTL_REMOVE_AT_2024_APRIL binder1st : public unary_function<typename Operation::second_argument_type, typename Operation::result_type>
{
Expand All @@ -377,6 +378,7 @@ namespace eastl
typename Operation::result_type operator()(typename Operation::second_argument_type& x) const
{ return op(value, x); }
};
EASTL_INTERNAL_RESTORE_DEPRECATED()


EASTL_INTERNAL_DISABLE_DEPRECATED() // 'eastl::binder1st<Operation>': was declared deprecated
Expand All @@ -390,6 +392,7 @@ namespace eastl

/// bind2nd
///
EASTL_INTERNAL_DISABLE_DEPRECATED() // unariy_function is deprecated
template <typename Operation>
class EASTL_REMOVE_AT_2024_APRIL binder2nd : public unary_function<typename Operation::first_argument_type, typename Operation::result_type>
{
Expand All @@ -407,6 +410,7 @@ namespace eastl
typename Operation::result_type operator()(typename Operation::first_argument_type& x) const
{ return op(x, value); }
};
EASTL_INTERNAL_RESTORE_DEPRECATED()


EASTL_INTERNAL_DISABLE_DEPRECATED() // 'eastl::binder2nd<Operation>': was declared deprecated
Expand Down
8 changes: 7 additions & 1 deletion include/EASTL/internal/type_pod.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,14 @@ namespace eastl
#define EASTL_DECLARE_TRIVIAL_DESTRUCTOR(T) namespace eastl{ template <> struct EASTL_REMOVE_AT_2024_APRIL has_trivial_destructor<T> : public true_type{}; template <> struct EASTL_REMOVE_AT_2024_APRIL has_trivial_destructor<const T> : public true_type{}; }

#if EASTL_VARIABLE_TEMPLATES_ENABLED
// Note: some compilers (notably GCC) trigger deprecation warnings in template variable
// declarations even if the variable is not insantiated here, so turn the warning off
// here. If this varialbe is used, the warning will still trigger in the user code, this
// just disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <class T>
EASTL_REMOVE_AT_2024_APRIL EA_CONSTEXPR bool has_trivial_destructor_v = has_trivial_destructor<T>::value;
EASTL_INTERNAL_RESTORE_DEPRECATED()
#endif


Expand Down Expand Up @@ -993,7 +999,7 @@ namespace eastl
#else

// If the compiler has this trait built-in (which ideally all compilers would have since it's necessary for full conformance) use it.
#if EASTL_COMPILER_INTRINSIC_TYPE_TRAITS_AVAILABLE && ((defined(__clang__) && EA_COMPILER_HAS_FEATURE(is_trivially_constructible)) || defined(EA_COMPILER_MSVC))
#if EASTL_COMPILER_INTRINSIC_TYPE_TRAITS_AVAILABLE && ((EASTL_HAS_INTRINSIC(is_trivially_constructible)) || defined(EA_COMPILER_MSVC))
#define EASTL_TYPE_TRAIT_is_trivially_constructible_CONFORMANCE 1

// We have a problem with clang here as of clang 3.4: __is_trivially_constructible(int[]) is false, yet I believe it should be true.
Expand Down
12 changes: 12 additions & 0 deletions include/EASTL/internal/type_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,31 @@ namespace eastl

template<typename> struct EASTL_REMOVE_AT_2024_APRIL result_of;

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template<typename F, typename... ArgTypes>
struct EASTL_REMOVE_AT_2024_APRIL result_of<F(ArgTypes...)>
{ typedef decltype(eastl::declval<F>()(eastl::declval<ArgTypes>()...)) type; };
EASTL_INTERNAL_RESTORE_DEPRECATED()


// result_of_t is the C++14 using typedef for typename result_of<T>::type.
// We provide a backwards-compatible means to access it through a macro for pre-C++11 compilers.
#if defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
#define EASTL_RESULT_OF_T(T) typename result_of<T>::type
#else
// Note: some compilers (notably GCC) trigger deprecation warnings in template variable
// declarations even if the variable is not insantiated here, so turn the warning off
// here. If this varialbe is used, the warning will still trigger in the user code, this
// just disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <typename T>
using result_of_t EASTL_REMOVE_AT_2024_APRIL = typename result_of<T>::type;
#define EASTL_RESULT_OF_T(T) result_of_t<T>
EASTL_INTERNAL_RESTORE_DEPRECATED()
#endif


Expand Down
26 changes: 26 additions & 0 deletions include/EASTL/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ namespace eastl
};


// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <typename Iterator>
struct EASTL_REMOVE_AT_2024_SEPT is_iterator_wrapper_helper<Iterator, true>
{
Expand All @@ -238,6 +243,7 @@ namespace eastl
template <typename Iterator>
EASTL_REMOVE_AT_2024_SEPT inline typename is_iterator_wrapper_helper<Iterator, eastl::is_iterator_wrapper<Iterator>::value>::iterator_type unwrap_iterator(Iterator it)
{ return eastl::is_iterator_wrapper_helper<Iterator, eastl::is_iterator_wrapper<Iterator>::value>::get_unwrapped(it); }
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand Down Expand Up @@ -424,9 +430,15 @@ namespace eastl
struct EASTL_REMOVE_AT_2024_SEPT is_reverse_iterator
: public eastl::false_type {};

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template<typename Iterator>
struct EASTL_REMOVE_AT_2024_SEPT is_reverse_iterator<eastl::reverse_iterator<Iterator>>
: public eastl::true_type {};
EASTL_INTERNAL_RESTORE_DEPRECATED()

/// unwrap_reverse_iterator is not implemented since there's no
/// good use case and there's some abiguitiy. Note that
Expand Down Expand Up @@ -642,9 +654,15 @@ namespace eastl
struct EASTL_REMOVE_AT_2024_SEPT is_move_iterator
: public eastl::false_type {};

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template<typename Iterator>
struct EASTL_REMOVE_AT_2024_SEPT is_move_iterator<eastl::move_iterator<Iterator>>
: public eastl::true_type {};
EASTL_INTERNAL_RESTORE_DEPRECATED()


/// unwrap_move_iterator
Expand All @@ -656,12 +674,14 @@ namespace eastl
/// eastl::move_iterator<vector<int>::iterator> moveIterator(intVector.begin());
/// vector<int>::iterator it = unwrap_move_iterator(moveIterator);
///
EASTL_INTERNAL_DISABLE_DEPRECATED() // is_iterator_wrapper_helper is deprecated
template <typename Iterator>
EASTL_REMOVE_AT_2024_SEPT inline typename eastl::is_iterator_wrapper_helper<Iterator, eastl::is_move_iterator<Iterator>::value>::iterator_type unwrap_move_iterator(Iterator it)
{
// get_unwrapped(it) -> it.unwrap() which is equivalent to `it.base()` for move_iterator and to `it` otherwise.
return eastl::is_iterator_wrapper_helper<Iterator, eastl::is_move_iterator<Iterator>::value>::get_unwrapped(it);
}
EASTL_INTERNAL_RESTORE_DEPRECATED()


/// back_insert_iterator
Expand Down Expand Up @@ -856,9 +876,15 @@ namespace eastl
struct EASTL_REMOVE_AT_2024_SEPT is_insert_iterator
: public eastl::false_type {};

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template<typename Iterator>
struct EASTL_REMOVE_AT_2024_SEPT is_insert_iterator<eastl::insert_iterator<Iterator>>
: public eastl::true_type {};
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand Down
6 changes: 3 additions & 3 deletions include/EASTL/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ namespace eastl
return *this;
}

raw_storage_iterator<OutputIterator, T>& operator++()
raw_storage_iterator& operator++()
{
++mIterator;
return *this;
}

raw_storage_iterator<OutputIterator, T> operator++(int)
raw_storage_iterator operator++(int)
{
raw_storage_iterator<OutputIterator, T> tempIterator = *this;
raw_storage_iterator tempIterator = *this;
++mIterator;
return tempIterator;
}
Expand Down
30 changes: 30 additions & 0 deletions include/EASTL/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,19 @@ namespace eastl
template <bool bCondition, class ConditionIsTrueType, class ConditionIsFalseType>
struct EASTL_REMOVE_AT_2024_APRIL type_select { typedef ConditionIsTrueType type; };

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <typename ConditionIsTrueType, class ConditionIsFalseType>
struct EASTL_REMOVE_AT_2024_APRIL type_select<false, ConditionIsTrueType, ConditionIsFalseType> { typedef ConditionIsFalseType type; };

#if EASTL_VARIABLE_TEMPLATES_ENABLED
template <bool bCondition, class ConditionIsTrueType, class ConditionIsFalseType>
using type_select_t EASTL_REMOVE_AT_2024_APRIL = typename type_select<bCondition, ConditionIsTrueType, ConditionIsFalseType>::type;
#endif
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand Down Expand Up @@ -379,8 +385,14 @@ namespace eastl
template <bool b1, bool b2, bool b3, bool b4, bool b5>
struct EASTL_REMOVE_AT_2024_APRIL type_or { static const bool value = true; };

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <>
struct EASTL_REMOVE_AT_2024_APRIL type_or<false, false, false, false, false> { static const bool value = false; };
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand All @@ -399,8 +411,14 @@ namespace eastl
template <bool b1, bool b2, bool b3, bool b4, bool b5>
struct EASTL_REMOVE_AT_2024_APRIL type_and{ static const bool value = false; };

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <>
struct EASTL_REMOVE_AT_2024_APRIL type_and<true, true, true, true, true>{ static const bool value = true; };
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand Down Expand Up @@ -436,8 +454,14 @@ namespace eastl
template <bool b>
struct EASTL_REMOVE_AT_2024_APRIL type_not{ static const bool value = true; };

// Note: some compilers (notably GCC) trigger deprecation warnings when doing template
// specialization if the main template is derpecated, so turn the warning off here. If this
// specialization is used, the warning will still trigger in the user code, this just
// disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
template <>
struct EASTL_REMOVE_AT_2024_APRIL type_not<true>{ static const bool value = false; };
EASTL_INTERNAL_RESTORE_DEPRECATED()



Expand Down Expand Up @@ -576,10 +600,16 @@ namespace eastl
template <typename T>
struct EASTL_REMOVE_AT_2024_APRIL identity { using type = T; };

// Note: some compilers (notably GCC) trigger deprecation warnings in template variable
// declarations even if the variable is not insantiated here, so turn the warning off
// here. If this varialbe is used, the warning will still trigger in the user code, this
// just disables the warning in this declaration.
EASTL_INTERNAL_DISABLE_DEPRECATED()
#if EASTL_VARIABLE_TEMPLATES_ENABLED
template <typename T>
using identity_t EASTL_REMOVE_AT_2024_APRIL = typename identity<T>::type;
#endif
EASTL_INTERNAL_RESTORE_DEPRECATED()


///////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ target_include_directories(EASTLTest PUBLIC include)
FetchContent_Declare(
EABase
GIT_REPOSITORY https://github.com/electronicarts/EABase.git
GIT_TAG c11d898e3d175c9e957df86e4afe5403429f57f1
GIT_TAG 123363eb82e132c0181ac53e43226d8ee76dea12
GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EABase.
)
FetchContent_MakeAvailable(EABase)
Expand Down

0 comments on commit 9ea79f7

Please sign in to comment.