std::destroy(std::begin(*p), std::end(*p)) (C++20 起)。 在某常量表达式 e 的求值中调用 destroy_at 时,参数 p 必须指向用 std::allocator<T>::allocate 获得的存储或生存期始于 e 的求值内的对象。 (C++20 起)参数p - 指向要被销毁的对象的指针 返回值...
destroy_at 推导要销毁的对象类型,从而避免在析构函数调用中显式写出它。 在某常量表达式 e 的求值中调用 destroy_at 时,参数 p 必须指向生存期始于 e 的求值内的对象。 (C++20 起)示例下列示例演示如何用 destroy_at 销毁元素的相接序列。 运行此代码 #include <iostream> #include <memory> #include <...
for(;first!=last;++first)std::destroy_at(std::addressof(*first)); 2)同(1),但按照policy执行。此重载不参与重载决议,除非std::is_execution_policy_v<std::decay_t<ExecutionPolicy>>为 true 。 参数 first, last-要销毁的元素的范围 policy-所用的执行策略。细节见执行策略。
constexpr void destroy_at( T* p ) noexcept; (since C++20) If T is not an array type, calls the destructor of the object pointed to by p, as if by p->~T(). Otherwise, recursively destroys elements of *p in order, as if by calling std::destroy(std::begin(*p), std::end(*p...
template<class ForwardIt, class Size> constexpr // C++20 起 ForwardIt destroy_n( ForwardIt first, Size n ) { for (; n > 0; (void) ++first, --n) std::destroy_at(std::addressof(*first)); return first; } 示例 下列示例演示如何用 destroy_n 销毁元素的相接序列。运行...
true false true using std::swap;swap(val, rhs.val); std::construct_at(std::addressof(unex), std::move(rhs.unex));std::destroy_at(std::addressof(rhs.unex));has_val = false;rhs.has_val = true; false other.swap(*this); using std::swap;swap(unex, rhs.unex); This...
std::destroy_at std::destroy_n std::difftime std::disjunction std::divides std::divides<void> std::domain_error std::dynamic_pointer_cast std::enable_if std::enable_shared_from_this std::enable_shared_from_this::enable_shared_from_this std::enable_shared_from_this::shared_from_this st...
std::destroy_at std::destroy_n std::difftime std::disjunction std::divides std::divides<void> std::domain_error std::dynamic_pointer_cast std::enable_if std::enable_shared_from_this std::enable_shared_from_this::enable_shared_from_this std::enable_shared_from_this::shared_from_this st...
std::destroy_at std::destroy_n std::difftime std::disjunction std::divides std::divides<void> std::domain_error std::dynamic_pointer_cast std::enable_if std::enable_shared_from_this std::enable_shared_from_this::enable_shared_from_this std::enable_shared_from_this::shared_from_this st...
参数 p-指向将在其上构造T对象的未初始化存储的指针 args...-用于初始化的参数 返回值 示例 本节未完成 原因:暂无示例 参阅 construct [静态] 在分配的存储构造对象 (函数模板) destroy_at (C++17) 销毁在给定地址的对象 (函数模板)