C++Guns – RoboBlog


C++ Guns: print std::array with std::integer_sequence

Filed under: Allgemein — Tags: — Thomas @ 15:05

Part1: print std::array with std:integer_sequence
Part2: convert tuple to parameter pack
Part 3: print std::array with std::apply and fold

Wird an der Zeit, dass ich das auch mal versuche:

#include <array>
#include <iostream>

template<size_t N, std::size_t... Ints>
void print_impl(const std::array<double,N>& arr, std::index_sequence<Ints...>) {
    ((std::cout << std::get<Ints>(arr)),...);

template<size_t N>
void print(const std::array<double,N>& arr) {
    print_impl(arr, std::make_index_sequence<N>{});

void func() {
    std::array<double,4> arr{1,2,3,4};

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress