has_posix_clock_traits.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2025 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/has_posix_clock_traits.hpp
  10. *
  11. * This header contains utilities for working with \c posix_clock_traits.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_HAS_POSIX_CLOCK_TRAITS_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_HAS_POSIX_CLOCK_TRAITS_HPP_INCLUDED_
  15. #include <sys/types.h> // clockid_t
  16. #include <type_traits>
  17. #include <boost/atomic/posix_clock_traits_fwd.hpp>
  18. #include <boost/atomic/detail/config.hpp>
  19. #include <boost/atomic/detail/header.hpp>
  20. #ifdef BOOST_HAS_PRAGMA_ONCE
  21. #pragma once
  22. #endif
  23. namespace boost {
  24. namespace atomics {
  25. namespace detail {
  26. template< typename Clock >
  27. struct has_posix_clock_traits_impl
  28. {
  29. template< typename T, clockid_t = posix_clock_traits< T >::clock_id >
  30. static std::true_type check_posix_clock_traits_clock_id(T*);
  31. static std::false_type check_posix_clock_traits_clock_id(...);
  32. using type = decltype(has_posix_clock_traits_impl< Clock >::check_posix_clock_traits_clock_id(static_cast< Clock* >(nullptr)));
  33. };
  34. //! Checks if there exists a specialization of \c posix_clock_traits for \c Clock
  35. template< typename Clock >
  36. using has_posix_clock_traits = typename has_posix_clock_traits_impl< Clock >::type;
  37. } // namespace detail
  38. } // namespace atomics
  39. } // namespace boost
  40. #include <boost/atomic/detail/footer.hpp>
  41. #endif // BOOST_ATOMIC_DETAIL_HAS_POSIX_CLOCK_TRAITS_HPP_INCLUDED_