🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
741 B

  1. #ifndef ENTT_CORE_TUPLE_HPP
  2. #define ENTT_CORE_TUPLE_HPP
  3. #include <tuple>
  4. #include <type_traits>
  5. #include <utility>
  6. #include "../config/config.h"
  7. namespace entt {
  8. /**
  9. * @brief Utility function to unwrap tuples of a single element.
  10. * @tparam Type Tuple type of any sizes.
  11. * @param value A tuple object of the given type.
  12. * @return The tuple itself if it contains more than one element, the first
  13. * element otherwise.
  14. */
  15. template<typename Type>
  16. constexpr decltype(auto) unwrap_tuple(Type &&value) ENTT_NOEXCEPT {
  17. if constexpr(std::tuple_size_v<std::remove_reference_t<Type>> == 1u) {
  18. return std::get<0>(std::forward<Type>(value));
  19. } else {
  20. return std::forward<Type>(value);
  21. }
  22. }
  23. } // namespace entt
  24. #endif