Tagged Questions
2
votes
3answers
56 views
boost shared_ptr cycling reference?
From boost documentation on boost::shared_ptr:
Because the implementation uses reference counting, cycles of
shared_ptr instances will not be reclaimed. For example, if main()
holds a ...
-1
votes
0answers
68 views
invalid delete boost shared_ptr in std::map with unit_test_framework
I have looked for an answer everywhere, but I cannot manage to understand what is going on...
I'm building a shared library (.so) with 2 files:
common_database.h:
#ifndef COMMON_DATABASE_H_
#define ...
0
votes
1answer
65 views
Error while using boost::shared_ptr
I'm learning boost and smart pointers. During compilation I got an error, and I can't figure out what is it about. I don't understand what I am doing wrong. The problem is in constructor:
...
6
votes
4answers
222 views
Smart pointer wrapping penalty. Memoization with std::map
I am currently in the middle of a project where performance is of vital importance. Following are some of the questions I had regarding this issue.
Question1
My project involves plenty of ...
1
vote
2answers
98 views
What smart pointer should I use in this case?
I have a class, ResourceManifest, which loads 3d models from a file and keeps them in a vector and then hands them out as requested. It is also possible to delete the cached 3dmodel from storage and I ...
1
vote
1answer
92 views
How would I return a class from a function that doesn't have a copy constructor?
I'm using boost Asio, and the following function will not compile.
udp::resolver Create_UDP_Socket(){
boost::asio::io_service io_service;
udp::socket s(io_service, udp::endpoint(udp::v4(), ...
4
votes
5answers
130 views
Name for smart pointer/coding pattern
Recently I've been frequently running into situations where I needed something similar to this data structure.
Restrictions: C++03 standard.
+-----+--------------+ +----+
|node0| ...
1
vote
1answer
69 views
Replacement of Poco::AutoPtr with boost
I am trying to replace Poco::AutoPtr with some alternative in boost. Here is what I have discovered so far:
What I have: below classess are being used with Poco::AutoPtr. They need to implement ...
0
votes
7answers
103 views
What are the alternatives to references and standard pointers for returning local variables in C++?
I am fairly new to C++ and I know of three ways of returning a local variable and all have their downsides:
Person& getPerson()
{
Person bob;
return bob;
}
Clearly not a good idea.
...
1
vote
1answer
137 views
Polymorphic casts with boost::shared_ptr
I'm familiar with boost's polymorphic_cast on normal pointers:
Base *base;
Derived *d = boost::polymorphic_cast<Derived>(base);
But, how to use it with boost::shared_ptr instead?
...
0
votes
3answers
157 views
Boost shared_ptr does not destroy the object immediately
I am developing a Bayesian inference sampler in C++, which relays much on a tree, and this tree is implemented with the help of smart pointers (Boost's shared_ptr and weak_ptr).
During inference ...
3
votes
1answer
131 views
Using custom smart pointers in boost python
I would like to expose objects wrapped in custom smart pointers in python using Boost::Python
The caveats
existing usage of the custom smart pointer is too pervasive to
economically upgrade to the ...
2
votes
1answer
160 views
OpenCV or Boost smart pointers
I have an expanding image processing project which relies heavily on the OpenCV library for much of its functionality, although I do also use a few boost functions as well.
I'd like to start using ...
5
votes
3answers
175 views
Why can't intrusive_ptr and shared_ptr be used with boost::intrusive containers?
The boost::intrusive documentation describes how you can use smart pointers with intrusive containers but then says you can't use the smart pointers you'd be most likely to use, "It must have the same ...
1
vote
2answers
130 views
Is there such a thing as a shared reference count smart pointer?
Programmers using boost::shared_ptr need to avoid cycles so that a resource leak is not created. The general advice is to use a boost::weak_ptr in the cases where such a cycle might be created. ...
1
vote
3answers
122 views
Embedded reference count with Boost shared_ptr
I love Boost's smart_ptr features and the ability to convert to and from a shared_ptr and weak_ptr, but since the reference count is not contained in the pointed class itself, the following code does ...
1
vote
2answers
61 views
Handling exception before the assigning of a scoped_ptr
A member of my class is a boost::scoped_ptr which is set to (T*)0 when the object is created. The class has an init() method that actually initializes the smart pointer with a new object.
However, if ...
0
votes
2answers
173 views
Boost Shared Pointer Constructors/Destructors
I'm trying to implement smart pointers in my code. I've created a class to convert a Point to a shared_ptr and I've added a print function for the shared_ptr. In my main, I create an array of ...
2
votes
1answer
57 views
Calling Inherited Class Specific Functions in C++
I have the following problem. I am busy coding up an inheritance structure in C++. Briefly, this is what I am attempting to do. Class A is the base class and classes B and C are inherited class. ...
0
votes
6answers
227 views
C++ intrusive_ptr issue
I want to use boost::intrusive_ptr for refcounting my class x::Y, so I add a references field and friend declarations for the release and add_ref functions, which should be defined in namespace boost. ...
1
vote
1answer
169 views
boost::shared_ptr inside QList leads to segmentation fault
i have a strange problem with QList and the boost:shared_ptr. I'm afraid i am not able to strip the problem apart, that's why i will post the wholoe function later on.
What i want to do: I have a ...
1
vote
2answers
74 views
Acceptable way to expose an object manager's objects?
Scenario is, I'm building a game with a TextureManager class that is responsible for loading and managing textures. Game objects implementing IVisibleGameObject will need a pointer/reference to a ...
2
votes
2answers
213 views
Conditional boost::shared_ptr initialization?
In an effort to write better code, I've committed to using boost's smart pointers.
Should a boost::shared_ptr always be initialized like so?
boost::shared_ptr<TypeX> px(new TypeX);
My ...
1
vote
2answers
176 views
Smart pointer to wrap array returned by a library
I'm running VC++ 2005 so std::unique_ptr is not available AFAIK. I use some library functions (black box) which effectively do return new T[n] and I want to wrap the result in some object which will ...
1
vote
1answer
202 views
What are some reasons not to use unique_ptr<> as a class member? [closed]
I'm trying to determine uses cases where it's appropriate or advisable to use this smart pointer to contain class members that are pointers.
1
vote
4answers
319 views
Performance of auto_ptr vs. shared_ptr
I didn't find information about performance issues with auto_ptr and shared_ptr(I use tr1 implementation). As shared_ptr is more complicated compared to auto_ptr so auto_ptr is faster? So in general ...
1
vote
2answers
285 views
C++, Boost: How to store objects of an abstract type in a map container
I am trying to use a map container to hold Shapes and match those shapes to an ID number.
Until now, I have always used STL containers to hold and memory-manage my objects. So I would use containers ...
1
vote
2answers
217 views
Passing a Boost smart pointer to the thread function
I have a situation where some object has to be passed as an argument of a thread callback function. Object is created dynamically and after it is passed to the thread, object is not needed/used in ...
0
votes
2answers
183 views
Simple boost smart pointer syntax issue
When using either boost::scoped_ptr or boost::shared_ptr I get the error
1>*\algomanager.cpp(28) : error C2064: term does not evaluate to a
function taking 1 arguments
I have code like this . ...
2
votes
1answer
268 views
boost::scoped_array::get() in return statement
I have the following code:
std::string HtmlToText( std::string const& html )
{
boost::scoped_array<char> text( converter.toText( html.c_str() ) );
return text.get();
}
My concern ...