This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "tools/fill.hpp"
template <class T, class Allocator, typename V>
void fill(std::vector<T, Allocator>& vector, const V& value);
It fills all the elements of a multi-dimensional vector at once.
Let us assume that the type of v
is std::vector<std::vector<std::vector<int>>>
.
After calling tools::fill(v, -1);
, all of v[x][y][z]
will be $-1$.
#ifndef TOOLS_FILL_HPP
#define TOOLS_FILL_HPP
#include <type_traits>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstddef>
#include <array>
#include "tools/is_range.hpp"
namespace tools {
template <class T, class Allocator, typename V>
::std::enable_if_t<!::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value) {
::std::fill(::std::begin(vector), ::std::end(vector), value);
}
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<!::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value) {
::std::fill(::std::begin(array), ::std::end(array), value);
}
template <class T, class Allocator, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value);
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value);
template <class T, class Allocator, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value) {
for (auto& child : vector) {
::tools::fill(child, value);
}
}
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value) {
for (auto& child : array) {
::tools::fill(child, value);
}
}
}
#endif
#line 1 "tools/fill.hpp"
#include <type_traits>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstddef>
#include <array>
#line 1 "tools/is_range.hpp"
#line 6 "tools/is_range.hpp"
#include <utility>
namespace tools {
template <typename T, typename = ::std::void_t<>>
struct is_range : ::std::false_type {};
template <typename T>
struct is_range<T, ::std::void_t<decltype(::std::begin(::std::declval<T>()), ::std::end(::std::declval<T>()))>> : ::std::true_type {};
template <typename T>
inline constexpr bool is_range_v = ::tools::is_range<T>::value;
}
#line 11 "tools/fill.hpp"
namespace tools {
template <class T, class Allocator, typename V>
::std::enable_if_t<!::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value) {
::std::fill(::std::begin(vector), ::std::end(vector), value);
}
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<!::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value) {
::std::fill(::std::begin(array), ::std::end(array), value);
}
template <class T, class Allocator, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value);
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value);
template <class T, class Allocator, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::vector<T, Allocator>& vector, const V& value) {
for (auto& child : vector) {
::tools::fill(child, value);
}
}
template <class T, ::std::size_t N, typename V>
::std::enable_if_t<::tools::is_range_v<T>, void> fill(::std::array<T, N>& array, const V& value) {
for (auto& child : array) {
::tools::fill(child, value);
}
}
}