algorithm-dev

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub today2098/algorithm-dev

:warning: 多次元配列生成
(algorithm/Utils/table.hpp)

概要

std::vector による多次元配列を再帰的に生成する.

参考文献

  1. “可変引数テンプレート [N2242]”. cpprefjp. https://cpprefjp.github.io/lang/cpp11/variadic_templates.html.

Code

#ifndef ALGORITHM_TABLE_HPP
#define ALGORITHM_TABLE_HPP 1

#include <vector>

namespace algorithm {

template <typename Type>
std::vector<Type> table(std::size_t n, const Type &val) { return std::vector<Type>(n, val); }

template <typename... Args>
auto table(std::size_t n, const Args &...args) { return std::vector(n, table(args...)); }

}  // namespace algorithm

#endif
#line 1 "algorithm/Utils/table.hpp"



#include <vector>

namespace algorithm {

template <typename Type>
std::vector<Type> table(std::size_t n, const Type &val) { return std::vector<Type>(n, val); }

template <typename... Args>
auto table(std::size_t n, const Args &...args) { return std::vector(n, table(args...)); }

}  // namespace algorithm
Back to top page