From 785f7994c7a961992f1bc4838d376d7bb556557b Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Thu, 12 Sep 2019 18:12:02 -0600 Subject: [PATCH] Fix VecTraits internal compile errors with GCC 4.8 GCC 4.8 seems to have issues with the templated using statements in VecTraits. Hopefully this change works around that problem. --- vtkm/VecTraits.h | 62 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/vtkm/VecTraits.h b/vtkm/VecTraits.h index 357e27167..cc3f19afe 100644 --- a/vtkm/VecTraits.h +++ b/vtkm/VecTraits.h @@ -183,6 +183,26 @@ struct VTKM_NEVER_EXPORT VecTraits : VecTraits { }; +#if defined(VTKM_GCC) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +namespace detail +{ + +template +struct VecReplaceComponentTypeGCC48 +{ + using type = vtkm::Vec; +}; + +template +struct VecReplaceBaseComponentTypeGCC48 +{ + using type = + vtkm::Vec::template ReplaceBaseComponentType, Size>; +}; + +} // namespace detail +#endif // GCC Version 4.8 + template struct VTKM_NEVER_EXPORT VecTraits> { @@ -247,26 +267,42 @@ struct VTKM_NEVER_EXPORT VecTraits> vector[component] = value; } - /// \brief Get a vector of the same type but with a different component. - /// - /// This type resolves to another vector with a different component type. For example, - /// vtkm::VecTraits>::ReplaceComponentType is vtkm::Vec. - /// This replacement is not recursive. So VecTraits, N>::ReplaceComponentType - /// is vtkm::Vec. - /// +/// \brief Get a vector of the same type but with a different component. +/// +/// This type resolves to another vector with a different component type. For example, +/// vtkm::VecTraits>::ReplaceComponentType is vtkm::Vec. +/// This replacement is not recursive. So VecTraits, N>::ReplaceComponentType +/// is vtkm::Vec. +///@{ +#if defined(VTKM_GCC) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) + // Silly workaround for bug in GCC 4.8 + template + using ReplaceComponentType = + typename detail::VecReplaceComponentTypeGCC48::type; +#else // !GCC 4.8 template using ReplaceComponentType = vtkm::Vec; +#endif +///@} - /// \brief Get a vector of the same type but with a different base component. - /// - /// This type resolves to another vector with a different base component type. The replacement - /// is recursive for nested types. For example, - /// VecTraits, N>::ReplaceComponentType is Vec, N>. - /// +/// \brief Get a vector of the same type but with a different base component. +/// +/// This type resolves to another vector with a different base component type. The replacement +/// is recursive for nested types. For example, +/// VecTraits, N>::ReplaceComponentType is Vec, N>. +///@{ +#if defined(VTKM_GCC) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) + // Silly workaround for bug in GCC 4.8 + template + using ReplaceBaseComponentType = + typename detail::VecReplaceBaseComponentTypeGCC48::type; +#else // !GCC 4.8 template using ReplaceBaseComponentType = vtkm::Vec< typename vtkm::VecTraits::template ReplaceBaseComponentType, Size>; +#endif + ///@} /// Converts whatever type this vector is into the standard VTKm Tuple. ///