Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve is_tuple_like trait #2970

Merged
merged 1 commit into from Oct 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 22 additions & 15 deletions hpx/traits/is_tuple_like.hpp
Expand Up @@ -3,29 +3,36 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#if !defined(HPX_TRAITS_IS_TUPLE_LIKE_HPP)
#ifndef HPX_TRAITS_IS_TUPLE_LIKE_HPP
#define HPX_TRAITS_IS_TUPLE_LIKE_HPP

#include <type_traits>

#include <hpx/util/always_void.hpp>
#include <hpx/util/tuple.hpp>

namespace hpx {
namespace traits {
namespace hpx { namespace traits
{
namespace detail
{
template <typename T, typename Enable = void>
struct is_tuple_like_impl
: std::false_type
{};

template <typename T>
struct is_tuple_like_impl<T, typename util::always_void<
decltype(util::tuple_size<T>::value)>::type
> : std::true_type
{};
}

/// Deduces to a true type if the given parameter T
/// has a specific tuple like size.
template <typename T, typename = void>
struct is_tuple_like : std::false_type
{
};
template <typename T>
struct is_tuple_like<T,
typename util::always_void<decltype(util::tuple_size<T>::value)>::type>
: std::true_type
{
};
} // namespace traits
} // namespace hpx
struct is_tuple_like
: detail::is_tuple_like_impl<typename std::remove_cv<T>::type>
{};
}}

#endif
#endif /*HPX_TRAITS_IS_TUPLE_LIKE_HPP*/