最終更新日時(UTC): 2024年06月11日 13時45分38秒 Akira Takahashi が更新
履歴 編集
[[nodiscard]] constexpr bool empty() const noexcept;
参照している範囲が空かどうかを判定する。
以下と等価:
return size() == 0;
投げない
定数時間
#include <cassert> #include <span> #include <vector> int main() { std::vector<int> v = {1, 2, 3, 4, 5}; int* p = v.data(); std::size_t n = 0; assert(!std::span{v}.empty()); assert(std::span{v}.first(0).empty()); assert((std::span<int>{p, n}.empty())); }