One of the C++0x improvements that will allow to write more efficient C++ code is the unique_ptr smart pointer (too bad, that it will not allow moving through memmove() like operations: the proposal didn't make into the draft).
What are other performance improvements in upcoming standard? Take following code for example:
vector<char *>...
I do know:
It wasn't in the CTP
It's slated to be in the final release
I can't find it in Beta 1
I want to play with it
...
Hello,
I have a class containing a std::unique_ptr<> and I want to put instances of this class inside of an std::map<>. I thought one of the things that motivated the introduction of move semantics to C++ was the possibility of putting things like unique_ptrs inside standard containers (and that really works, in the case of vectors). Bu...
I'm currently trying to use Howard Hinnant's unique_ptr implementation, and am running into a compile error. Here is some sample code:
struct Base {};
struct Derived : public Base {};
void testfun(boost::unique_ptr<Base>);
void test()
{
unique_ptr<Derived> testDerived;
unique_ptr<Base> testBase(move(testDerived)); // ok, con...
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 instead?
...
#include <vector>
#include <memory>
using namespace std;
class A {
public:
A(): i(new int) {}
A(A const& a) = delete;
A(A &&a): i(move(a.i)) {}
unique_ptr<int> i;
};
class AGroup {
public:
void AddA(A &&a) { a_.emplace_back(move(a)); }
vector<A> a_;
};
int main() {
AGroup ag;
ag.Ad...
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>> uniqueCollection;
Now I would expect the following to fail, as there is no telling what the algorithm is doing internally and maybe making internal pivot copies...
Hi all,
I've recently started using Boost.Asio in a project and would like to know whether anyone knows a clean solution to transfer ownership of a newly created socket to tcp::acceptor::async_accept, which would in turn transfer this ownership to the accept handler function.
This isn't an incoherent desire, mind you, since the handler...
Say I have a std::list of class T's:
std::list<T> l;
When passing it into functions, I would use a reference:
someFunction( std::list<T> &l )
What is the best way to pass around (the elements) of a std::list of unique_ptrs?
std::list< std::unique_ptr<T> > l;
Like this:
someFunction( std::unique_ptr<T> ptr )
Or this:
someFun...
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 I can do a global find/replace on my code (not that I would do this, but if I did)) or should I be aware of some differences that are not ap...
If my class SomeType has a method that returns a element from the map (using the key) say
std::unique_ptr<OtherType> get_othertype(std::string name)
{
return otMap.find(name);
}
that would enure the caller would recieve a pointer to the one in the map rather than a copy? Is it ok to do this, or would it try and call the copy const...
Why can I not do this?
typedef boost::interprocess::unique_ptr<QueueList, QueueListDeletor> UQList;
typedef boost::intrusive::list<UQList> List; // Compiler (VS 2003) complains
The QueueList is a class that derives from public boost::intrusive::list_base_hook<> to make it part of an intrusive linked list.
I want to use unique_ptr ...
I have a for loop that iterates through an XML document and finds a specified attribute, the pointer that points to the current node sits inside a boost::interprocess::unique_ptr and has a custom deletor to call the object's release() function. It seems that on every loop iteration the pointer gets deleted, but the release() function th...