Google OR-Tools: ortools/base/array.h Source File

Go to the documentation of this file.

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef ORTOOLS_BASE_ARRAY_H_

15#define ORTOOLS_BASE_ARRAY_H_

16

18

19#include <array>

20#include <cstddef>

21#include <type_traits>

22

23#include "absl/utility/utility.h"

24

26

28

29template <typename T, std::size_t N, std::size_t... Idx>

31 T (&ts)[N], absl::index_sequence<Idx...>) {

32 return {{ts[Idx]...}};

33}

34

35template <typename T, std::size_t N, std::size_t... Idx>

37 T (&&ts)[N], absl::index_sequence<Idx...>) {

38 return {{std::move(ts[Idx])...}};

39}

40

41}

42

43template <typename T, std::size_t N>

44constexpr std::array<std::remove_cv_t<T>, N> to_array(T (&ts)[N]) {

46}

47

48template <typename T, std::size_t N>

49constexpr std::array<std::remove_cv_t<T>, N> to_array(T (&&ts)[N]) {

51 absl::make_index_sequence<N>{});

52}

53

54}

55

56#endif

constexpr std::array< std::remove_cv_t< T >, N > to_array_internal(T(&ts)[N], absl::index_sequence< Idx... >)

Definition array.h:30

constexpr std::array< std::remove_cv_t< T >, N > to_array(T(&ts)[N])

Definition array.h:44