Commit 768086a0 authored by Allison Vacanti's avatar Allison Vacanti

Merge branch 'upstream-taotuple' into cuda_32bit_id_fix

* upstream-taotuple:
  taotuple 2018-06-29 (4bd72b5e)
parents b4110cd5 d4b38a78
The MIT License (MIT)
Copyright (c) 2015 Daniel Frey
Copyright (c) 2015-2018 Daniel Frey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# The Art of C++ / Tuple
[![Release](https://img.shields.io/github/release/taocpp/tuple.svg)](https://github.com/taocpp/tuple/releases/latest)
[![License](https://img.shields.io/github/license/taocpp/tuple.svg)](#license)
[![TravisCI](https://travis-ci.org/taocpp/tuple.svg)](https://travis-ci.org/taocpp/tuple)
[![Issues](https://img.shields.io/github/issues/taocpp/tuple.svg)](https://github.com/taocpp/tuple/issues)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/9opt30ae579kw19b/branch/master?svg=true)](https://ci.appveyor.com/project/taocpp/tuple)
The Art of C++ / Tuple is a C++11 header-only reference implementation of
[The Art of C++](https://taocpp.github.io/) / Tuple is a C++11 header-only reference implementation of
[`std::tuple`](http://en.cppreference.com/w/cpp/utility/tuple).
## Rationale
......@@ -35,7 +34,7 @@ of 15 on the same system.
The Art of C++ is certified [Open Source](http://www.opensource.org/docs/definition.html) software. It may be used for any purpose, including commercial purposes, at absolutely no cost. It is distributed under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.html) reproduced here.
> Copyright (c) 2015 Daniel Frey
> Copyright (c) 2015-2018 Daniel Frey
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
......
......@@ -37,6 +37,20 @@
#endif // __CUDACC__
#endif // TAOCPP_ANNOTATION
// Ignore "calling a __host__ function from a __host__ _device__ function is not allowed" warnings
#ifndef TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
#ifdef __CUDACC__
#if __CUDAVER__ >= 75000
#define TAO_TUPLE_SUPPRESS_NVCC_HD_WARN #pragma nv_exec_check_disable
#else
#define TAO_TUPLE_SUPPRESS_NVCC_HD_WARN #pragma hd_warning_disable
#endif
#else
#define TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
#endif
#endif
namespace simple_tuple
{
namespace detail
......@@ -49,26 +63,31 @@ protected:
Head Value;
public:
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
TAOCPP_ANNOTATION constexpr tuple_leaf()
: Value()
{
}
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
TAOCPP_ANNOTATION constexpr tuple_leaf(const Head& value)
: Value(value)
{
}
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
TAOCPP_ANNOTATION constexpr tuple_leaf(const tuple_leaf& o)
: Value(o.Value)
{
}
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
TAOCPP_ANNOTATION constexpr tuple_leaf(tuple_leaf&& o)
: Value(std::move(o.Value))
{
}
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
template <typename Other>
TAOCPP_ANNOTATION constexpr tuple_leaf(Other&& o)
: Value(std::forward<Other>(o))
......@@ -82,6 +101,7 @@ public:
return o.Value;
}
TAO_TUPLE_SUPPRESS_NVCC_HD_WARN
TAOCPP_ANNOTATION
tuple_leaf& operator=(tuple_leaf& o)
{
......
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAO_SEQ_AT_INDEX_HPP
#define TAO_SEQ_AT_INDEX_HPP
#include <cstddef>
#include "make_integer_sequence.hpp"
namespace tao
{
namespace seq
{
// based on http://talesofcpp.fusionfenix.com/post-22/true-story-efficient-packing
namespace impl
{
template< std::size_t, typename T >
struct indexed
{
using type = T;
};
template< typename, typename... Ts >
struct indexer;
template< std::size_t... Is, typename... Ts >
struct indexer< index_sequence< Is... >, Ts... >
: indexed< Is, Ts >...
{
};
template< std::size_t I, typename T >
indexed< I, T > select( const indexed< I, T >& );
} // namespace impl
template< std::size_t I, typename... Ts >
using at_index = decltype( impl::select< I >( impl::indexer< index_sequence_for< Ts... >, Ts... >() ) );
#ifndef _MSC_VER
template< std::size_t I, typename... Ts >
using at_index_t = typename at_index< I, Ts... >::type;
#else
namespace impl
{
template< typename T >
struct get_type
{
using type = typename T::type;
};
} // namespace impl
template< std::size_t I, typename... Ts >
using at_index_t = typename impl::get_type< at_index< I, Ts... > >::type;
#endif
} // namespace seq
} // namespace tao
#endif
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
#ifndef TAOCPP_SEQUENCES_INCLUDE_CONCATENATE_HPP
#define TAOCPP_SEQUENCES_INCLUDE_CONCATENATE_HPP
#include <type_traits>
#include "integer_sequence.hpp"
namespace tao
{
namespace seq
{
template< typename, typename >
struct concatenate;
template< typename TA, TA... As, typename TB, TB... Bs >
struct concatenate< integer_sequence< TA, As... >, integer_sequence< TB, Bs... > >
{
using type = integer_sequence< typename std::common_type< TA, TB >::type, As..., Bs... >;
};
template< typename A, typename B >
using concatenate_t = typename concatenate< A, B >::type;
}
}
#endif // TAOCPP_SEQUENCES_INCLUDE_CONCATENATE_HPP
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAOCPP_SEQUENCES_INCLUDE_CONFIG_HPP
#define TAOCPP_SEQUENCES_INCLUDE_CONFIG_HPP
#ifndef TAO_SEQ_CONFIG_HPP
#define TAO_SEQ_CONFIG_HPP
#if __cplusplus >= 201402L
# define TAOCPP_USE_STD_INTEGER_SEQUENCE
#endif
#include <utility>
#if (__cplusplus >= 201402L) && defined(_LIBCPP_VERSION)
# define TAOCPP_USE_STD_MAKE_INTEGER_SEQUENCE
#ifndef TAO_SEQ_USE_STD_INTEGER_SEQUENCE
#if defined( __cpp_lib_integer_sequence )
#define TAO_SEQ_USE_STD_INTEGER_SEQUENCE
#elif defined( _LIBCPP_VERSION ) && ( __cplusplus >= 201402L )
#define TAO_SEQ_USE_STD_INTEGER_SEQUENCE
#elif defined( _MSC_VER )
#define TAO_SEQ_USE_STD_INTEGER_SEQUENCE
#endif
#endif
#if defined(__cpp_fold_expressions)
# define TAOCPP_FOLD_EXPRESSIONS
#elif __cplusplus > 201402L
# if defined(__apple_build_version__) && (__clang_major__ >= 7)
# define TAOCPP_FOLD_EXPRESSIONS
# elif defined(__clang__) && ((__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ >= 6)))
# define TAOCPP_FOLD_EXPRESSIONS
# endif
#ifndef TAO_SEQ_USE_STD_MAKE_INTEGER_SEQUENCE
#if defined( _GLIBCXX_RELEASE ) && ( _GLIBCXX_RELEASE >= 8 ) && ( __cplusplus >= 201402L )
#define TAO_SEQ_USE_STD_MAKE_INTEGER_SEQUENCE
#elif defined( _LIBCPP_VERSION ) && ( __cplusplus >= 201402L )
#define TAO_SEQ_USE_STD_MAKE_INTEGER_SEQUENCE
#elif defined( _MSC_VER ) && ( _MSC_FULL_VER >= 190023918 )
#define TAO_SEQ_USE_STD_MAKE_INTEGER_SEQUENCE
#endif
#endif
#ifndef TAOCPP_ANNOTATION
#ifdef __CUDACC__
#define TAOCPP_ANNOTATION __host__ __device__
#else
#define TAOCPP_ANNOTATION
#endif // __CUDACC__
#endif // TAOCPP_ANNOTATION
#if defined( __cpp_fold_expressions ) && ( !defined( __GNUC__ ) || ( __GNUC__ >= 8 ) )
#define TAO_SEQ_FOLD_EXPRESSIONS
#endif
#endif // TAOCPP_SEQUENCES_INCLUDE_CONFIG_HPP
#endif
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAOCPP_SEQUENCES_INCLUDE_EXCLUSIVE_SCAN_HPP
#define TAOCPP_SEQUENCES_INCLUDE_EXCLUSIVE_SCAN_HPP
#ifndef TAO_SEQ_EXCLUSIVE_SCAN_HPP
#define TAO_SEQ_EXCLUSIVE_SCAN_HPP
#include <utility>
......@@ -11,33 +11,38 @@
namespace tao
{
namespace seq
{
namespace impl
{
template< typename S, typename = make_index_sequence< S::size() > >
struct exclusive_scan;
template< typename S, std::size_t... Is >
struct exclusive_scan< S, index_sequence< Is... > >
namespace seq
{
namespace impl
{
template< typename S, typename = make_index_sequence< S::size() > >
struct exclusive_scan;
template< typename S, std::size_t... Is >
struct exclusive_scan< S, index_sequence< Is... > >
{
using type = integer_sequence< typename S::value_type, partial_sum< Is, S >::value... >;
};
} // namespace impl
template< typename T, T... Ns >
struct exclusive_scan
: impl::exclusive_scan< integer_sequence< T, Ns... > >
{
};
template< typename T, T... Ns >
struct exclusive_scan< integer_sequence< T, Ns... > >
: impl::exclusive_scan< integer_sequence< T, Ns... > >
{
using type = integer_sequence< typename S::value_type, partial_sum< Is, S >::value... >;
};
}
template< typename T, T... Ns >
struct exclusive_scan
: impl::exclusive_scan< integer_sequence< T, Ns... > >
{};
template< typename T, T... Ns >
using exclusive_scan_t = typename exclusive_scan< T, Ns... >::type;
template< typename T, T... Ns >
struct exclusive_scan< integer_sequence< T, Ns... > >
: impl::exclusive_scan< integer_sequence< T, Ns... > >
{};
} // namespace seq
template< typename T, T... Ns >
using exclusive_scan_t = typename exclusive_scan< T, Ns... >::type;
}
}
} // namespace tao
#endif // TAOCPP_SEQUENCES_INCLUDE_EXCLUSIVE_SCAN_HPP
#endif
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
#ifndef TAOCPP_SEQUENCES_INCLUDE_FOLD_HPP
#define TAOCPP_SEQUENCES_INCLUDE_FOLD_HPP
#include <type_traits>
#include "values.hpp"
#include "integer_sequence.hpp"
#include "make_integer_sequence.hpp"
namespace tao
{
namespace seq
{
namespace impl
{
template< template< typename U, U, U > class, typename, bool, typename T, T... >
struct folder;
template< template< typename U, U, U > class OP, std::size_t... Is, typename T, T... Ns >
struct folder< OP, index_sequence< Is... >, false, T, Ns... >
{
using values = seq::values< T, Ns... >;
using type = integer_sequence< T, OP< T, values::data[ 2 * Is ], values::data[ 2 * Is + 1 ] >::value... >;
};
template< template< typename U, U, U > class OP, std::size_t... Is, typename T, T N, T... Ns >
struct folder< OP, index_sequence< Is... >, true, T, N, Ns... >
{
using values = seq::values< T, Ns... >;
using type = integer_sequence< T, N, OP< T, values::data[ 2 * Is ], values::data[ 2 * Is + 1 ] >::value... >;
};
}
template< template< typename U, U, U > class, typename T, T... >
struct fold;
template< template< typename U, U, U > class OP, typename T, T N >
struct fold< OP, T, N >
: std::integral_constant< T, N >
{};
template< template< typename U, U, U > class OP, typename T, T... Ns >
struct fold
: fold< OP, typename impl::folder< OP, make_index_sequence< sizeof...( Ns ) / 2 >, sizeof...( Ns ) % 2 == 1, T, Ns... >::type >
{};
template< template< typename U, U, U > class OP, typename T, T... Ns >
struct fold< OP, integer_sequence< T, Ns... > >
: fold< OP, T, Ns... >
{};
}
}
#endif // TAOCPP_SEQUENCES_INCLUDE_FOLD_HPP
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
#ifndef TAOCPP_SEQUENCES_INCLUDE_HEAD_HPP
#define TAOCPP_SEQUENCES_INCLUDE_HEAD_HPP
#include <type_traits>
#include "integer_sequence.hpp"
namespace tao
{
namespace seq
{
template< typename T, T... Ns >
struct head;
template< typename T, T N, T... Ns >
struct head< T, N, Ns... >
: std::integral_constant< T, N >
{};
template< typename T, T... Ns >
struct head< integer_sequence< T, Ns... > >
: head< T, Ns... >
{};
}
}
#endif // TAOCPP_SEQUENCES_INCLUDE_HEAD_HPP
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAOCPP_SEQUENCES_INCLUDE_INCLUSIVE_SCAN_HPP
#define TAOCPP_SEQUENCES_INCLUDE_INCLUSIVE_SCAN_HPP
#ifndef TAO_SEQ_INCLUSIVE_SCAN_HPP
#define TAO_SEQ_INCLUSIVE_SCAN_HPP
#include <utility>
#include "plus.hpp"
#include "exclusive_scan.hpp"
#include "integer_sequence.hpp"
#include "plus.hpp"
namespace tao
{
namespace seq
{
template< typename T, T... Ns >
struct inclusive_scan
: plus< exclusive_scan_t< T, Ns... >, integer_sequence< T, Ns... > >
{};
template< typename T, T... Ns >
struct inclusive_scan< integer_sequence< T, Ns... > >
: plus< exclusive_scan_t< integer_sequence< T, Ns... > >, integer_sequence< T, Ns... > >
{};
template< typename T, T... Ns >
using inclusive_scan_t = typename inclusive_scan< T, Ns... >::type;
}
}
#endif // TAOCPP_SEQUENCES_INCLUDE_INCLUSIVE_SCAN_HPP
namespace seq
{
template< typename T, T... Ns >
struct inclusive_scan
: plus< exclusive_scan_t< T, Ns... >, integer_sequence< T, Ns... > >
{
};
template< typename T, T... Ns >
struct inclusive_scan< integer_sequence< T, Ns... > >
: plus< exclusive_scan_t< integer_sequence< T, Ns... > >, integer_sequence< T, Ns... > >
{
};
template< typename T, T... Ns >
using inclusive_scan_t = typename inclusive_scan< T, Ns... >::type;
} // namespace seq
} // namespace tao
#endif
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAOCPP_SEQUENCES_INCLUDE_INTEGER_SEQUENCE_HPP
#define TAOCPP_SEQUENCES_INCLUDE_INTEGER_SEQUENCE_HPP
#ifndef TAO_SEQ_INTEGER_SEQUENCE_HPP
#define TAO_SEQ_INTEGER_SEQUENCE_HPP
#include <cstddef>
#include <utility>
......@@ -11,34 +11,34 @@
namespace tao
{
namespace seq
{
namespace seq
{
#ifdef TAOCPP_USE_STD_INTEGER_SEQUENCE
#ifdef TAO_SEQ_USE_STD_INTEGER_SEQUENCE
using std::integer_sequence;
using std::index_sequence;
using std::index_sequence;
using std::integer_sequence;
#else
template< typename T, T... Ns >
struct integer_sequence
{
using value_type = T;
TAOCPP_ANNOTATION
static constexpr std::size_t size() noexcept
template< typename T, T... Ns >
struct integer_sequence
{
return sizeof...( Ns );
}
};
using value_type = T;
static constexpr std::size_t size() noexcept
{
return sizeof...( Ns );
}
};
template< std::size_t... Ns >
using index_sequence = integer_sequence< std::size_t, Ns... >;
template< std::size_t... Ns >
using index_sequence = integer_sequence< std::size_t, Ns... >;
#endif
}
}
} // namespace seq
#endif // TAOCPP_SEQUENCES_INCLUDE_INTEGER_SEQUENCE_HPP
} // namespace tao
#endif
// The Art of C++ / Sequences
// Copyright (c) 2015 Daniel Frey
// Copyright (c) 2015-2018 Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/sequences/
#ifndef TAOCPP_SEQUENCES_INCLUDE_IS_ALL_HPP
#define TAOCPP_SEQUENCES_INCLUDE_IS_ALL_HPP
#ifndef TAO_SEQ_IS_ALL_HPP
#define TAO_SEQ_IS_ALL_HPP
#include "config.hpp"
#ifndef TAOCPP_FOLD_EXPRESSIONS
#ifndef TAO_SEQ_FOLD_EXPRESSIONS
#include "integer_sequence.hpp"
#endif
......@@ -14,22 +14,23 @@
namespace tao
{
namespace seq
{
namespace seq
{
#ifdef TAOCPP_FOLD_EXPRESSIONS
#ifdef TAO_SEQ_FOLD_EXPRESSIONS
template< bool... Bs >
using is_all = std::integral_constant< bool, ( Bs && ... ) >;
template< bool... Bs >
using is_all = std::integral_constant< bool, ( Bs && ... ) >;
#else
template< bool... Bs >
using is_all = std::integral_constant< bool, std::is_same< integer_sequence< bool, true, Bs... >, integer_sequence< bool, Bs..., true > >::value >;
template< bool... Bs >
using is_all = std::integral_constant< bool, std::is_same< integer_sequence< bool, true, Bs... >, integer_sequence< bool, Bs..., true > >::value >;
#endif
}