This documentation is automatically generated by online-judge-tools/verification-helper
#include "src/data_structure/ndvec.hpp"
#pragma once
/**
* @file ndvec.hpp
* @brief Nd-vector
*/
#include <vector>
#include "lib/cxx17"
namespace workspace {
template <class _Tp, size_t _Dim>
class ndvec : public std::vector<ndvec<_Tp, _Dim - 1>> {
public:
static constexpr auto dimension = _Dim;
using container_type = std::vector<ndvec<_Tp, _Dim - 1>>;
using size_type = typename container_type::size_type;
ndvec() = default;
template <size_t _Nm>
ndvec(const size_t (&__size)[_Nm], const _Tp& __x = {}) noexcept
: container_type(__size[_Nm - _Dim], {__size, __x}) {}
template <size_type _Nm = 0> size_type size() const noexcept {
_CXX17_STATIC_ASSERT(_Nm < dimension);
if _CXX17_CONSTEXPR (_Nm) {
return container_type::operator[](0).template size<_Nm - 1>();
}
return container_type::size();
}
void fill(const _Tp& __x) noexcept {
for (auto __i = container_type::begin(); __i != container_type::end();
++__i)
__i->fill(__x);
}
};
template <class _Tp> class ndvec<_Tp, 1> : public std::vector<_Tp> {
public:
static constexpr auto dimension = 1;
using container_type = std::vector<_Tp>;
using size_type = typename container_type::size_type;
ndvec() = default;
template <size_t _Nm>
ndvec(const size_t (&__size)[_Nm], const _Tp& __x = {}) noexcept
: container_type(__size[_Nm - 1], __x) {}
template <size_type _Nm = 0> size_type size() const noexcept {
_CXX17_STATIC_ASSERT(!_Nm);
return container_type::size();
}
void fill(const _Tp& __x) noexcept {
for (auto __i = container_type::begin(); __i != container_type::end();
++__i)
*__i = __x;
}
};
#if __cpp_deduction_guides >= 201606L
template <class _Tp, size_t _Dim>
ndvec(const size_t (&)[_Dim], const _Tp&) -> ndvec<_Tp, _Dim>;
#endif
} // namespace workspace
#line 2 "src/data_structure/ndvec.hpp"
/**
* @file ndvec.hpp
* @brief Nd-vector
*/
#include <vector>
#line 2 "lib/cxx17"
#line 2 "lib/cxx14"
#ifndef _CXX14_CONSTEXPR
#if __cplusplus >= 201402L
#define _CXX14_CONSTEXPR constexpr
#else
#define _CXX14_CONSTEXPR
#endif
#endif
#line 4 "lib/cxx17"
#ifndef _CXX17_CONSTEXPR
#if __cplusplus >= 201703L
#define _CXX17_CONSTEXPR constexpr
#else
#define _CXX17_CONSTEXPR
#endif
#endif
#ifndef _CXX17_STATIC_ASSERT
#if __cplusplus >= 201703L
#define _CXX17_STATIC_ASSERT static_assert
#else
#define _CXX17_STATIC_ASSERT assert
#endif
#endif
#include <iterator>
#if __cplusplus < 201703L
namespace std {
/**
* @brief Return the size of a container.
* @param __cont Container.
*/
template <typename _Container>
constexpr auto size(const _Container& __cont) noexcept(noexcept(__cont.size()))
-> decltype(__cont.size()) {
return __cont.size();
}
/**
* @brief Return the size of an array.
*/
template <typename _Tp, size_t _Nm>
constexpr size_t size(const _Tp (&)[_Nm]) noexcept {
return _Nm;
}
/**
* @brief Return whether a container is empty.
* @param __cont Container.
*/
template <typename _Container>
[[nodiscard]] constexpr auto empty(const _Container& __cont) noexcept(
noexcept(__cont.empty())) -> decltype(__cont.empty()) {
return __cont.empty();
}
/**
* @brief Return whether an array is empty (always false).
*/
template <typename _Tp, size_t _Nm>
[[nodiscard]] constexpr bool empty(const _Tp (&)[_Nm]) noexcept {
return false;
}
/**
* @brief Return whether an initializer_list is empty.
* @param __il Initializer list.
*/
template <typename _Tp>
[[nodiscard]] constexpr bool empty(initializer_list<_Tp> __il) noexcept {
return __il.size() == 0;
}
struct monostate {};
} // namespace std
#else
#include <variant>
#endif
#line 11 "src/data_structure/ndvec.hpp"
namespace workspace {
template <class _Tp, size_t _Dim>
class ndvec : public std::vector<ndvec<_Tp, _Dim - 1>> {
public:
static constexpr auto dimension = _Dim;
using container_type = std::vector<ndvec<_Tp, _Dim - 1>>;
using size_type = typename container_type::size_type;
ndvec() = default;
template <size_t _Nm>
ndvec(const size_t (&__size)[_Nm], const _Tp& __x = {}) noexcept
: container_type(__size[_Nm - _Dim], {__size, __x}) {}
template <size_type _Nm = 0> size_type size() const noexcept {
_CXX17_STATIC_ASSERT(_Nm < dimension);
if _CXX17_CONSTEXPR (_Nm) {
return container_type::operator[](0).template size<_Nm - 1>();
}
return container_type::size();
}
void fill(const _Tp& __x) noexcept {
for (auto __i = container_type::begin(); __i != container_type::end();
++__i)
__i->fill(__x);
}
};
template <class _Tp> class ndvec<_Tp, 1> : public std::vector<_Tp> {
public:
static constexpr auto dimension = 1;
using container_type = std::vector<_Tp>;
using size_type = typename container_type::size_type;
ndvec() = default;
template <size_t _Nm>
ndvec(const size_t (&__size)[_Nm], const _Tp& __x = {}) noexcept
: container_type(__size[_Nm - 1], __x) {}
template <size_type _Nm = 0> size_type size() const noexcept {
_CXX17_STATIC_ASSERT(!_Nm);
return container_type::size();
}
void fill(const _Tp& __x) noexcept {
for (auto __i = container_type::begin(); __i != container_type::end();
++__i)
*__i = __x;
}
};
#if __cpp_deduction_guides >= 201606L
template <class _Tp, size_t _Dim>
ndvec(const size_t (&)[_Dim], const _Tp&) -> ndvec<_Tp, _Dim>;
#endif
} // namespace workspace