Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
2 votes
1 answer
157 views

Consider the following code where I test whether a type is copy-assignable by using the std::is_copy_assignable_v type-trait: #include <print> #include <type_traits> struct IntProxy { ...
0 votes
2 answers
236 views

What is the copy-and-swap idiom? lists copy-and-swap as a better alternative to self-assignment check, being simpler and providing stronger exception guarantees. Performance aside, are there any ...
3 votes
2 answers
230 views

I came across this table describing how the C++ compiler implicitly declares special member functions depending on which ones the user has explicitly declared: Source: Howard Hinnant - How I Declare ...
0 votes
0 answers
102 views

I'm trying to understand copy assignment in C++. I know it's best to use copy-and-swap idiom for this operator. But for this simple class without consider the Exception safety, when will *ps = *(h.ps);...
6 votes
2 answers
253 views

This question is about how to implement assignment in modern C++ value types, with the goal of avoiding misleading code or code that is inconsistent with built-in behavior. In C++, generated values (...
0 votes
2 answers
103 views

class Test{ int num; const int constVal; int& ref; public: Test(int a):constVal(2),ref(a){ std::cout<<"create"<<std::endl; } }; int main() { ...
1 vote
1 answer
101 views

Problem Explanation Here's what I understood so far during last two month studying about Move semantics: Move constructor implicitly insert SomeClass::operator=(const SomeClass&) = delete at end ...
0 votes
0 answers
64 views

In an old closed-source codebase I came across a comment where the author suggests placing virtual base class copy assignment after those of immediate base classes or that it can result in "...
-1 votes
1 answer
93 views

I am new to C++ and trying to learn it the proper way. In particular, I am practicing a simple assignment operator overloading in the following class class Point { public: int x; int y; ...
0 votes
1 answer
49 views

I need some help eith the following code in Python, is an implementation of an ALNS heuristic for vrp that I'm trying to create. def run_heuristic(num_customers, num_vehicles, num_iterations, ...
1 vote
2 answers
264 views

I am reading Chapter 5 of the 2nd edition of A Tour of C++ by Bjarne Stroustrup. He is using an example implementation of Vector to convey his ideas and gets to the move constructor and shows the code ...
3 votes
1 answer
214 views

#include <iostream> #include <string> int main() { std::string a; std::string b; a + b = "dadas"; } PS D:\WeCode\local_c++> & 'c:\Users\z00841303.vscode\...
4 votes
1 answer
144 views

In C++ there is the infamous problem of self-assignment: when implementing operator=(const T &other), one has to be careful of the this == &other case to not destroy this's data before copying ...
0 votes
0 answers
51 views

I would like to understand when a copy constructor or assignment is called. Assume the following: class Foo { public: Foo() { cout << "foo constructor " << this <&...
0 votes
0 answers
58 views

[First of First: Vs2019 on Windows10, only C++11 supported] I've got confused on template copy assignment function like: enter image description here I found the specilization version is not working, ...

15 30 50 per page
1
2 3 4 5
...
11

AltStyle によって変換されたページ (->オリジナル) /