22 std::cout <<
"Does a primitive type support a nonthrowing copy constructor? "
23 << std::is_nothrow_copy_constructible_v<int> <<
std::endl;
25 std::cout <<
"Does a primitive type support a nonthrowing move constructor? "
26 << std::is_nothrow_move_constructible_v<int> <<
std::endl;
28 std::cout <<
"Does a primitive type support a nonthrowing copy assignment? "
29 << std::is_nothrow_copy_assignable_v<int> <<
std::endl;
31 std::cout <<
"Does a primitive type support a nonthrowing move assignment? "
35 std::cout <<
"Does a pod type support a nonthrowing copy constructor? "
36 << std::is_nothrow_copy_constructible_v<pod_type> <<
std::endl;
38 std::cout <<
"Does a pod type support a nonthrowing move constructor? "
39 << std::is_nothrow_move_constructible_v<pod_type> <<
std::endl;
41 std::cout <<
"Does a pod type support a nonthrowing copy assignment? "
42 << std::is_nothrow_copy_assignable_v<pod_type> <<
std::endl;
44 std::cout <<
"Does a pod type support a nonthrowing move assignment? "
48 std::cout <<
"Does an aggregate type support a nonthrowing copy constructor? "
49 << std::is_nothrow_copy_constructible_v<aggregate_type> <<
std::endl;
51 std::cout <<
"Does an aggregate type support a nonthrowing move constructor? "
52 << std::is_nothrow_move_constructible_v<aggregate_type> <<
std::endl;
54 std::cout <<
"Does an aggregate type support a nonthrowing copy assignment? "
55 << std::is_nothrow_copy_assignable_v<aggregate_type> <<
std::endl;
57 std::cout <<
"Does an aggregate type support a nonthrowing move assignment? "
64 bool m_invalid{
false};
68 if(this->m_invalid ==
false)
95 if(
this != std::addressof(rhs))
107 if(
this != std::addressof(rhs))
109 rhs.m_invalid =
true;
123template<
typename ElementType>
127 std::stack<ElementType> m_data;
140 template<
typename... Types>
143 std::lock_guard<std::mutex> lock(m_mutex);
144 m_data.emplace(std::forward<Types>(args)...);
154 std::lock_guard<std::mutex> lock(m_mutex);
155 if(m_data.empty())
throw std::exception{};
170 auto named_return_value = std::move(m_data.top());
176 std::cout <<
"The address of named_return_value: "
182 return named_return_value;
193 std::lock_guard<std::mutex> lock(m_mutex);
194 return m_data.empty();
204 auto top = stack.
pop();
void test_nonthrowing_copy_move_constructors_and_assignment()
void test_optimal_thread_safe_stack()
NonThrowingMovable(int v)
NonThrowingMovable & operator=(NonThrowingMovable &&rhs) noexcept
NonThrowingMovable(NonThrowingMovable &&rhs) noexcept
NonThrowingMovable(const NonThrowingMovable &rhs)
NonThrowingMovable & operator=(const NonThrowingMovable &rhs)
void push(Types &&... args)