Very insightful post and thank you for providing a very good explanation.
Type: Posts; User: Imanuel
Very insightful post and thank you for providing a very good explanation.
This question may qualify as a duplicate or be a candidate for closure so please notify and I am happy to delete it.
There is a plethora of information on networking in c++. Similar questions...
I don't see a problem with the notion of "self-taught" because we are taught or teach ourselves what we know through the process of learning. Any disinterest in learning and teaching (first or third...
If I choose to reallocate to a new size memory already constructed with a std::allocator, does this alleviate the need to destroy and deallocate prior to reallocation?
I don't think why not. I have yet to create a Windows Forms program in Visual Studio because I am still learning C++ but WF is suitable to make a GUI application with although I was told c# Forms...
Yes and thank you.
When specifying an amount or size_type to the allocate member of the std::allocator, how does that value translate to ::operator new with respect to the number of bytes requested?
Is it like...
Can you be a bit more specific as to the nature of the help needed? I presently write C++ in Visual Studio Professional so I may be of assistance.
So my problem was only allocating and not simultaneously constructing the memory leading to <Bad Ptr>. Ok thank you.
Not understanding this.
std::allocator<string> alloc;
auto const p = alloc.allocate(10);
Results in p have a <Bad Ptr> upon inspection.
Thank you for your reply. Per my text, reference count increment/decrement happens prior to pointer assignment.
I would discourage learning C++ with C. C++ is not C with wings. It is a language, at the surface, that differentiates itself from C although, under the hood, much of C++ is backed by C. The...
Why is it when reference counting, the copy-constructor increments this->counter but the copy-assignment increments ++*rhs.counter?
I am unable to work out in my head reasons for such. I...
This is not making any sense to me. I start two threads and when they are done, they call join. But what are they joining to? Who or what are they waiting for? Themselves to quit? The function...
"Blocks the current thread until the thread identified by *this finishes its execution. "
join() appears similar to function in Java but the description given in cppreference.com is a bit terse...
Can you provide a complete example?
I actually already understood that ... the primary reason for my compile-time errors. My question was eliciting how to use a unique_ptr inside a container when every container has a copy constructor...
I tried rearranging my code:
class World{
struct UniqueOrganism{
std::unique_ptr<Organism> unique_organism;
UniqueOrganism() {}
I wrote some code that produces this:
1>c:\users\comp sci\documents\visual studio 2010\projects\predatorpreysimulation\predatorpreysimulation\world.h(25): error C2665:...
No, I like it. I was just curious if Poo or Boo could be accessed via Foo but it appears any such access must be polymorphic and your example is quite clear there.
Very nice and I appreciate that perspective. By your post, I would say auto_ptr still has use when applicable and I will try all the solutions given to this thread.
No, to access Poo and Boo members through Foo; Foo has no members!
class Foo{
public:
};
class Poo : public Foo{
// local variables
public:
// Accessor/Mutator
};
But a move is not a copy correct? If I move a unique_ptr from one location to another inside a container, that does not entail copy right?
If this will never work I am happy to use auto_ptr for...
I can prob get around no copy or assign of unique_ptr by returning one from a function which the compiler allows just to stay in keeping with current convention.