Skip to main content
1 vote
1 answer
109 views

I want to do something like the following if (flag) { type1_t object = ..... } else { type2_t object = ..... } // do the same thing with object type1_t and type2_t are custom classes. The problem ...
roulette01's user avatar
  • 2,510
0 votes
1 answer
108 views

I've been reading the section on smart pointers in Scott Meyer's "Effective C++" and "More Effective C++." In it, there is an implementation of auto_ptr for which the constructor ...
twj's user avatar
  • 35
2 votes
1 answer
3k views

I have some 3rdparty libraries that are built as part of a large project. Some libraries require C++17, others require features that are removed in C++17 (std::auto_ptr, std::fun_ptr). For this ...
regomodo's user avatar
  • 755
2 votes
2 answers
122 views

What would be a simple C++ program where a std::vector<std::auto_ptr<T>> compiles but fails to execute correctly, whereas the same program with std::vector<std::unique_ptr<T>> ...
Mark Meretzky's user avatar
2 votes
1 answer
214 views

Suppose that we have void UsePointer (auto_ptr <CSomeClass> spObj) { spObj->DoSomething(); } and we have a main function: int main() { auto_ptr <CSomeClass> spObject (new ...
Lost1's user avatar
  • 1,062
2 votes
2 answers
469 views

I need to store my error and log messages to the file. This is the code sample: #include <fstream> #include <iostream> #include <memory> int main() { std::auto_ptr<std::...
Yury Finchenko's user avatar
1 vote
3 answers
360 views

I have referred to lot of StackOverflow links on these questions where the reason for auto_ptr not working well with STL is std::auto_ptr<> does not fulfill the requirements of being copy-...
anurag86's user avatar
  • 1,707
0 votes
0 answers
77 views

It is said that we should always use std::unique_ptr instead of std::auto_ptr and it is said that we were not able to store a auto_ptr in a container But consider this example: int main(int argc, ...
Itachi Uchiwa's user avatar
2 votes
2 answers
2k views

In the book "C++ Coding Standards. 101 Rules, Guidelines, and Best Practices" by Herb Sutter and Andrei Alexandrescu in Rule 52, the final quote is: "In rare cases, classes that have members of ...
Roman2452809's user avatar
0 votes
0 answers
85 views

As i was going through smart pointers, I ran through the following code. Works as expected. #include <iostream> #include <memory> using namespace std; class Double { public: Double(...
Newbie's user avatar
  • 204
0 votes
1 answer
472 views

auto_ptr doesn't support custom deleter and tr1 shared_ptr is not a good option for me. Are there any good options before c11 for unique_ptr/ auto_ptr look alike with custom deleter?
Peretz Levinov's user avatar
1 vote
1 answer
2k views

Is there a macro or compiler flag that would let me keep using auto_ptr in GCC 7/8 with -std=c++17? I have easily found the corresponding macro for clang and MSVC, but my Google-fu is not good enough ...
Violet Giraffe's user avatar
0 votes
0 answers
104 views

I'm trying to understand the flow of a code and I came across this code snippet in the header file typedef std::auto_ptr<Client> auto_ptr_t; static Client::auto_ptr_t open(const std::string&...
Abhay Nayak's user avatar
  • 1,109
0 votes
1 answer
320 views

Have shared project library that has to be compiled with various compilers C++17 C++03 etc. So just using the better unique_ptr or the less than perfect auto_ptr as appropriate is not ideal if the ...
Brian M's user avatar
0 votes
0 answers
72 views

I have the following test code that I'm trying to run on QNX 6.5.0SP1 using gcc 4.4.2: // auto_ptr::operator= example #include <iostream> #include <cstdio> #include <memory> std::...
JCowfer's user avatar
  • 140

15 30 50 per page
1
2 3 4 5
14