//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_std_aligned_union_h #define vtk_m_std_aligned_union_h #include #include #if defined(VTKM_USING_GLIBCXX_4) #include namespace vtkmstd { template struct max_size; template struct max_size { static constexpr std::size_t value = X; }; template struct max_size { static constexpr std::size_t other_value = max_size::value; static constexpr std::size_t value = (other_value > X0) ? other_value : X0; }; // This is to get around an apparent bug in GCC 4.8 where alianas(x) does not // seem to work when x is a constexpr. See // https://stackoverflow.com/questions/29879609/g-complains-constexpr-function-is-not-a-constant-expression template struct aligned_data_block { alignas(Alignment) char _s[Size]; }; template struct aligned_union { static constexpr std::size_t alignment_value = vtkmstd::max_size::value; using type = vtkmstd::aligned_data_block::value>; }; } // namespace vtkmstd #else // NOT VTKM_USING_GLIBCXX_4 namespace vtkmstd { using std::aligned_union; } // namespace vtkmstd #endif // NOT VTKM_USING_GLIBCXX_4 #endif //vtk_m_std_aligned_union_h