auto-ptr Questions
4
Solved
In C++/CLI , you can use native types in a managed class by it is not allowed to hold a member of a native class in a managed class : you need to use pointers in that case.
Here is an example :
c...
Gauzy asked 6/10, 2008 at 22:6
3
Solved
I'm reading some notes about shared pointers.
They say the first attempt by STL with the auto_ptr had the following major drawbacks:
They can't be used in STL containers
Copying the auto_ptr tran...
6
Solved
in my code I use HANDLEs from windows.h. They are used like
HANDLE h;
if (!openHandleToSomething(arg1, arg2, &h)) {
throw std::exception("openHandleToSomething error");
}
/* Use the handle in...
4
Solved
Why would I use get() with *, instead of just calling *?
Consider the following code:
auto_ptr<int> p (new int);
*p = 100;
cout << "p points to " << *p << '\n'; //100
aut...
Schonfeld asked 20/10, 2016 at 12:58
3
Solved
Consider the following code:
std::auto_ptr<std::string> p;
if (p.get() == 0) {
...
}
Is the get() member function a standard and reliable way for checking that p has not been initialized...
5
Solved
I heard auto_ptr is being deprecated in C++11. What is the reason for this?
Also I would like to know the difference between auto_ptr and shared_ptr.
Adon asked 13/9, 2010 at 3:23
5
Solved
This question raised after reading this tutorial:
http://www.cprogramming.com/tutorial/auto_ptr.html
There you can find the following statement: A subtle consequence of this behavior is that auto_...
4
Solved
Will auto_ptr be deprecated in incoming C++ standard?
Should unique_ptr be used for ownership transfer instead of shared_ptr?
If unique_ptr is not in the standard, then do I need to use shared_ptr...
Thiouracil asked 8/3, 2010 at 19:32
4
Solved
With the new standard coming (and parts already available in some compilers), the new type std::unique_ptr is supposed to be a replacement for std::auto_ptr.
Does their usage exactly overlap (so ...
Linsk asked 10/8, 2010 at 16:17
5
Solved
I am learning about smart pointers (std::auto_ptr) and just read here and here that smart pointers (std::auto_ptr) should not be put in containers (i.e. std::vector) because even most compilers won...
Pericarp asked 2/1, 2011 at 9:29
1
Solved
I do not fully understand the benefits of unique_ptr over auto_ptr, or I am not yet fully convinced why we need to use unique_ptr.
I see the following differences.
1) unique_ptr supports arrays a...
Childers asked 14/8, 2014 at 23:45
5
Solved
I'm new to auto pointer. I have this:
std::auto_ptr<myClass> myPointer(new MyClass(someArg));
How do I test whether I can instantiate myPointer successfully? I tried if (myPointer==NULL) a...
2
Solved
The following code does not compile on Visual C++ 2008 nor 2010:
#include <memory>
struct A {};
std::auto_ptr<A> foo() { return std::auto_ptr<A>(new A); }
const std::auto_ptr&...
1
Solved
What are the equivalent uses of each smart pointer in comparison to similar (but not limited to) some advanced techniques using raw pointers?
My understanding is minimal, but from what I can gathe...
Embouchure asked 16/8, 2013 at 2:0
2
Solved
While implementing a factory class I encountered a behavior of std::auto_ptr that I am not able to understand. I reduced the problem down to the following small program, so ... let's start.
Consid...
3
Solved
I am confused with unique_ptr and rvalue move philosophy.
Let's say we have two collections:
std::vector<std::auto_ptr<int>> autoCollection;
std::vector<std::unique_ptr<int>&...
Horologe asked 20/5, 2010 at 18:17
7
Solved
I have a class like this:
class Inner;
class Cont
{
public:
Cont();
virtual ~Cont();
private:
Inner* m_inner;
};
in the .cpp, the constructor creates an instance of Inner with new and the de...
Broody asked 23/12, 2009 at 10:23
6
Solved
2
I wrote this article and got some comments on it that confused me.
It basically boils down to my having seen T2 used only as a template parameter and mistakenly jumped to the conclusion that I cou...
Thermy asked 7/10, 2012 at 0:1
8
Solved
If I declare a temporary auto deleted character buffer using
std::auto_ptr<char> buffer(new char[n]);
then the buffer is automatically deleted when the buffer goes out of scope. I would as...
Triennial asked 4/11, 2008 at 9:31
1
Solved
I have a problem with auto_ptr in Exception classes, that I eventually reduced to:
#include <memory>
class MyException
{
std::auto_ptr<int> m_foo2;
};
int main()
{
try
{
throw My...
1
Solved
This site states on "Ownership, Sources, and Sinks" :
"When you copy an auto_ptr, you automatically transfer ownership from the source auto_ptr to the target auto_ptr; if the target auto_ptr alrea...
5
What can I do with 'move' (r-value references) in C++11 what I can't with std::auto_ptr? (As I understand they are different implementations of one idea.)
And old question again: is std::auto_ptr ...
Accuracy asked 11/12, 2011 at 16:27
3
Solved
auto_ptr_ref documentation here says this
This is an instrumental class to allow certain conversions that allow auto_ptr objects to be passed to and returned from functions.
Can somebody explain...
3
Solved
I have heard that auto pointers own their object whereas shared pointers can have many objects pointing to them. Why dont we use shared pointers all the time.
In relation to this what are smart po...
Internuncio asked 5/12, 2011 at 12:31
1 Next >
© 2022 - 2024 — McMap. All rights reserved.