Boost.Hana: std::integer_sequence< T, v > Struct Template Reference

| Boost.Hana 1.7.1 Your standard library for metaprogramming |

std::integer_sequence< T, v > Struct Template Reference
External adapters » Standard library adapters

## Description

### template<typename T, T ... v>
struct std::integer_sequence< T, v >

Adaptation of `std::integer_sequence` for Hana.

## Modeled concepts

1. `Comparable`
   Two `std::integer_sequence`s are equal if and only if they have the same number of elements, and if corresponding elements compare equal. The types of the elements held in both `integer_sequence`s may be different, as long as they can be compared.
   // Copyright Louis Dionne 2013-2017
   // Distributed under the Boost Software License, Version 1.0.
   // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
   #include <boost/hana/assert.hpp>
   #include <boost/hana/equal.hpp>
   #include <boost/hana/ext/std/integer_sequence.hpp>
   #include <boost/hana/not_equal.hpp>
   #include <utility>
   namespace hana = boost::hana;
   constexpr std::integer_sequence<int, 1, 2, 3, 4> xs{};
   constexpr std::integer_sequence<long, 1, 2, 3, 4> ys{};
   constexpr std::integer_sequence<long, 1, 2, 3, 4, 5> zs{};
   BOOST_HANA_CONSTANT_CHECK(hana::equal(xs, ys));
   BOOST_HANA_CONSTANT_CHECK(hana::not_equal(xs, zs));
   BOOST_HANA_CONSTANT_CHECK(hana::not_equal(ys, zs));
   int main() { }
   assert.hpp
   Defines macros to perform different kinds of assertions.
   equal.hpp
   Defines boost::hana::equal.
   boost::hana::equal
   constexpr auto equal
   Returns a Logical representing whether x is equal to y.
   Definition: equal.hpp:64
   boost::hana::not_equal
   constexpr auto not_equal
   Returns a Logical representing whether x is not equal to y.
   Definition: not_equal.hpp:54
   BOOST_HANA_CONSTANT_CHECK
   #define BOOST_HANA_CONSTANT_CHECK(...)
   Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...
   Definition: assert.hpp:239
   integer_sequence.hpp
   Adapts std::integer_sequence for use with Hana.
   boost::hana
   Namespace containing everything in the library.
   Definition: accessors.hpp:20
   not_equal.hpp
   Defines boost::hana::not_equal.
   std::integer_sequence
   Adaptation of std::integer_sequence for Hana.
   Definition: integer_sequence.hpp:60
2. `Foldable`
   Folding an `integer_sequence` is equivalent to folding a sequence of `std::integral_constant`s with the corresponding types.
   // Copyright Louis Dionne 2013-2017
   // Distributed under the Boost Software License, Version 1.0.
   // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
   #include <boost/hana/assert.hpp>
   #include <boost/hana/ext/std/integer_sequence.hpp>
   #include <boost/hana/unpack.hpp>
   #include <tuple>
   #include <utility>
   namespace hana = boost::hana;
   auto add = [](auto a, auto b, auto c) { return a + b + c; };
   int main() {
   std::tuple<int, long, double> tuple{1, 2l, 3.3};
   auto sum = hana::unpack(std::integer_sequence<int, 0, 1, 2>{}, [&](auto ...i) {
   // the `i`s are `std::integral_constant<int, ...>`s
   return add(std::get<decltype(i)::value>(tuple)...);
   });
   BOOST_HANA_RUNTIME_CHECK(sum == 6.3);
   }
   boost::hana::value
   constexpr auto value
   Return the compile-time value associated to a constant.
   Definition: value.hpp:54
   boost::hana::sum
   constexpr auto sum
   Compute the sum of the numbers of a structure.
   Definition: sum.hpp:66
   boost::hana::unpack
   constexpr auto unpack
   Invoke a function with the elements of a Foldable as arguments.
   Definition: unpack.hpp:79
   BOOST_HANA_RUNTIME_CHECK
   #define BOOST_HANA_RUNTIME_CHECK(...)
   Equivalent to BOOST_HANA_RUNTIME_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTIO...
   Definition: assert.hpp:209
   std::tuple
   Adapter for std::tuples.
   Definition: tuple.hpp:49
   unpack.hpp
   Defines boost::hana::unpack.
3. `Iterable`
   Iterating over an `integer_sequence` is equivalent to iterating over a sequence of the corresponding `std::integral_constant`s.
   // Copyright Louis Dionne 2013-2017
   // Distributed under the Boost Software License, Version 1.0.
   // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
   #include <boost/hana/assert.hpp>
   #include <boost/hana/at.hpp>
   #include <boost/hana/equal.hpp>
   #include <boost/hana/ext/std/integer_sequence.hpp>
   #include <boost/hana/ext/std/integral_constant.hpp>
   #include <type_traits>
   #include <utility>
   namespace hana = boost::hana;
   constexpr std::integer_sequence<int, 0, 1, 2, 3, 4> indices{};
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::at_c<2>(indices),
   std::integral_constant<int, 2>{}
   ));
   int main() { }
   at.hpp
   Defines boost::hana::at and boost::hana::at_c.
   integral_constant.hpp
   Adapts std::integral_constant for use with Hana.
   std::integral_constant
   Adapter for std::integral_constants.
   Definition: integral_constant.hpp:37
4. `Searchable`
   Searching through an `integer_sequence` is equivalent to searching through the corresponding sequence of `std::integral_constant`s.
   // Copyright Louis Dionne 2013-2017
   // Distributed under the Boost Software License, Version 1.0.
   // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
   #include <boost/hana/assert.hpp>
   #include <boost/hana/equal.hpp>
   #include <boost/hana/ext/std/integer_sequence.hpp>
   #include <boost/hana/ext/std/integral_constant.hpp>
   #include <boost/hana/find.hpp>
   #include <boost/hana/integral_constant.hpp>
   #include <boost/hana/optional.hpp>
   #include <type_traits>
   #include <utility>
   namespace hana = boost::hana;
   constexpr std::integer_sequence<int, 1, 2, 3, 4> xs{};
   BOOST_HANA_CONSTANT_CHECK(hana::equal(
   hana::find(xs, hana::int_c<3>),
   hana::just(std::integral_constant<int, 3>{})
   ));
   int main() { }
   find.hpp
   Defines boost::hana::find.
   boost::hana::find
   constexpr auto find
   Finds the value associated to the given key in a structure.
   Definition: find.hpp:44
   integral_constant.hpp
   Defines boost::hana::integral_constant.
   optional.hpp
   Defines boost::hana::optional.