opt_storage.hpp 824 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (C) 2023 Christian Mazakas
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_UNORDERED_DETAIL_OPT_STORAGE_HPP
  6. #define BOOST_UNORDERED_DETAIL_OPT_STORAGE_HPP
  7. #include <boost/config.hpp>
  8. #include <memory>
  9. namespace boost {
  10. namespace unordered {
  11. namespace detail {
  12. template <class T> union opt_storage
  13. {
  14. BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS T t_;
  15. opt_storage() {}
  16. ~opt_storage() {}
  17. T* address() noexcept { return std::addressof(t_); }
  18. T const* address() const noexcept { return std::addressof(t_); }
  19. };
  20. } // namespace detail
  21. } // namespace unordered
  22. } // namespace boost
  23. #endif // BOOST_UNORDERED_DETAIL_OPT_STORAGE_HPP