pimpl-idiom Questions
5
Solved
In the section on "Good Encapsulation" in Code Complete, it is recommended to hide private implementation details. An example is given in C++. The idea is basically to completely separate the inter...
Tirpitz asked 12/6, 2011 at 4:12
3
Solved
d-pointers are heavily used in Qt, they are an implementation of pimpl idiom. I know advantages and disadvantages of pimpl idiom. But I have missed the advantages of d-pointers implementation. Here...
Tracee asked 13/2, 2011 at 11:57
8
Solved
There have been a few questions on SO about the pimpl idiom, but I'm more curious about how often it is leveraged in practice.
I understand there are some trade-offs between performance and encaps...
Zita asked 9/5, 2009 at 14:10
4
Solved
When I use the pimpl idiom, is it a good idea to put all the methods definitions inside the class definition? For example:
// in A.h
class A {
class impl;
boost::scoped_ptr<impl> pimpl;
p...
Gland asked 23/12, 2010 at 9:32
4
Solved
boost::shared_ptr really bothers me. Certainly, I understand the utility of such a thing, but I wish that I could use the shared_ptr<A> as an A*. Consider the following code
class A
{
public...
Unprintable asked 10/12, 2010 at 16:8
3
Solved
Per my previous question, I wish that a boost::shared_ptr<A> was actually a subclass of A (or perhaps A*) so that it could be used in methods that took A* as their argument.
Consider the fol...
Grayback asked 10/12, 2010 at 16:57
3
Solved
After reading about the pimpl idiom I was horrified!
Isn't there a tool out there that can inspect a .h/.cpp file and deduce what dependencies could be waivered?
Jettiejettison asked 25/11, 2010 at 14:2
7
Solved
Consider the following:
PImpl.hpp
class Impl;
class PImpl
{
Impl* pimpl;
PImpl() : pimpl(new Impl) { }
~PImpl() { delete pimpl; }
void DoSomething();
};
PImpl.cpp
#include "PImpl.hpp"
#in...
Brunei asked 30/8, 2010 at 3:33
2
Solved
I recently switched back from Java and Ruby to C++, and much to my surprise I have to recompile files that use the public interface when I change the method signature of a private method, because a...
Fallingout asked 22/6, 2010 at 11:2
3
Solved
Sometimes, C++'s notion of privacy just baffles me :-)
class Foo
{
struct Bar;
Bar* p;
public:
Bar* operator->() const
{
return p;
}
};
struct Foo::Bar
{
void baz()
{
std::cout <...
Afro asked 1/6, 2010 at 18:21
5
(Yes, I know that one machine instruction usually doesn't matter. I'm asking this question because I want to understand the pimpl idiom, and use it in the best possible way; and because sometimes I...
Armandarmanda asked 21/5, 2010 at 8:19
2
Solved
What kind of tricks can be used to minimize the workload of implementing pImpl classes?
Header:
class Foo {
struct Impl;
boost::scoped_ptr<Impl> self;
public:
Foo(int arg);
~Foo();
// ...
Statolatry asked 1/3, 2010 at 2:7
5
I'd like to design a class Foo that stores various data of different types and returns iterators over them. It's supposed to be generic, so the user of Foo does not know how the data is stored (Foo...
Worlock asked 20/2, 2010 at 20:20
7
Solved
Is there any reason for the implementation class as used in the pimpl idiom to have any private members at all? The only reason I can really think of is to protect yourself from yourself -- i.e. th...
Disassociate asked 1/2, 2010 at 16:36
3
Solved
Pimpl's are a source of boilerplate in a lot of C++ code. They seem like the kind of thing that a combination of macros, templates, and maybe a little external tool help could solve, but I'm not su...
Cushitic asked 25/10, 2009 at 17:18
6
Solved
One problem in large C++ projects can be build times. There is some class high up in your dependency tree which you would need to work on, but usually you avoid doing so because every build takes a...
Salomesalomi asked 9/6, 2009 at 23:24
5
Solved
I want to use pimpl idiom with inheritance.
Here is the base public class and its implementation class:
class A
{
public:
A(){pAImpl = new AImpl;};
void foo(){pAImpl->foo();};
private:
AI...
Sacha asked 29/1, 2009 at 11:44
6
Solved
As I understand, the pimpl idiom is exists only because C++ forces you to place all the private class members in the header. If the header were to contain only the public interface, theoretically, ...
Gardol asked 6/11, 2008 at 15:56
© 2022 - 2024 — McMap. All rights reserved.