Skip to content

Commit

Permalink
Recursive fall-back for Xcode 7/8
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Jun 24, 2018
1 parent ce5f8b8 commit f98a6ac
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions include/tao/seq/type_by_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
#include <cstddef>
#include <type_traits>

#if defined( __apple_build_version__ ) && ( __apple_build_version__ >= 7000000 ) && ( __apple_build_version__ < 9000000 ) && ( __cplusplus >= 201402L )
#define TAOCPP_SEQUENCES_RECURSIVE_TYPE_BY_INDEX
#endif

#ifndef TAOCPP_SEQUENCES_RECURSIVE_TYPE_BY_INDEX
#include "make_integer_sequence.hpp"
#endif

namespace tao
{
namespace seq
{
#ifndef TAOCPP_SEQUENCES_RECURSIVE_TYPE_BY_INDEX

namespace impl
{
template< typename T >
Expand Down Expand Up @@ -44,6 +52,25 @@ namespace tao
template< std::size_t I, typename... Ts >
using type_by_index = decltype( impl::select_type< I >( impl::type_union< index_sequence_for< Ts... >, Ts... >{} ) );

#else

template< std::size_t I, typename... Ts >
struct type_by_index;

template< typename T, typename... Ts >
struct type_by_index< 0, T, Ts... >
{
using type = T;
};

template< std::size_t I, typename T, typename... Ts >
struct type_by_index< I, T, Ts... >
: type_by_index< I - 1, Ts... >
{
};

#endif

template< std::size_t I, typename... Ts >
using type_by_index_t = typename type_by_index< I, Ts... >::type;

Expand Down

0 comments on commit f98a6ac

Please sign in to comment.