pimpl-idiom Questions

2

Solved

Yesterday I ran into misery which took me 24 hours of frustration. The problem boiled down to unexpected crashes occurring on random basis. To complicate things, debugging reports had absolutely ra...
Bozovich asked 15/3, 2013 at 20:52

2

I was experimenting with C11 and VLAs, trying to declare a struct variable on the stack with only an incomplete declaration. The objective is to provide a mechanism to create a variable of some str...
Andino asked 27/8, 2014 at 23:6

4

Solved

I have something like the following: // foo.h: class foo { public: foo(); ~foo(); // note: the param type repetition here is only incidental, assume the // functions can't easily be made to s...
Asper asked 10/4, 2015 at 22:45

1

Solved

I apologize for the large amount of code required to demonstrate the issue. I am having a problem using the pimpl idiom with std::unique_ptr. Specifically the problem seems to occur when one class ...
Neolith asked 28/2, 2015 at 20:17

1

Solved

Especially in connection with std::vector it is important that types are noexcept movable when possible. So when declaring a move constructor = default like in struct Object1 { Object1(Object1 &...
Hannan asked 22/2, 2015 at 17:33

2

Solved

My current project involves writing a C++ API and I have decided to use the PIMPL idiom. Should I use the PIMPL idiom everywhere in my project, for example I need to create a custom class th...
Tabular asked 15/12, 2014 at 10:47

11

Solved

Backgrounder: The PIMPL Idiom (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library ...
Scolopendrid asked 13/9, 2008 at 14:30

1

Solved

Suppose I have a class with a private member, which is an implementation detail that clients of the class don't care about. This class is a value type and we want it to be copyable, eg #include &l...
Palate asked 15/10, 2014 at 8:50

3

The canonical form of the pimpl idiom (from Herb Sutter's "Exceptional C++") is as follows: class X { public: /* ... public members ... */ protected: /* ... protected members? ... */ private: ...
Scenography asked 18/9, 2014 at 7:18

1

Solved

PIMPL stands for Pointer to IMPLementation. The implementation stands for "implementation detail": something that the users of the class need not to be concerned with. Qt's own class implementatio...
Frisbie asked 11/8, 2014 at 18:39

4

Solved

I've been playing with the Pimpl idiom and reaping all sorts of benefits from it. The only thing I haven't been too keen on is the feeling I get when I define the functions. Once in the header (...
Subliminal asked 8/7, 2014 at 15:3

3

Solved

I usually use a boost::scoped_ptr for pimpl's (for one reason because then I don't get surprises if I forget to deal with the copy constructor) With templates however I can't just put the destruc...
Intenerate asked 5/12, 2011 at 14:5

1

Solved

In the following example, how is it possible that ~CImpl is called correctly but when the class needs to be moved, the compiler says it has an incomplete type? If the declaration of Impl is moved ...
Morgenthaler asked 26/2, 2014 at 16:45

1

Solved

Lets consider following example (using c++11) A.hpp: #include <memory> class A { public: //A(); //~A(); private: struct AImpl; std::unique_ptr<AImpl> pImpl; }; main.cpp...
Socialize asked 11/2, 2014 at 10:27

1

Solved

I was mucking about in some old library code, with the basic objective of refactoring it. This old code does not exactly comply to best practices and beauty (yes - friends are bad, and it has been ...
Percolation asked 15/1, 2014 at 10:2

3

Solved

D has a fantastic module system which reduces compilation times dramatically compared to C++. According to the documentation D still provides opaque structs and unions in order to enable the pimpl ...
Vankirk asked 9/12, 2013 at 11:42

0

I have this big C++ boostified project that takes ages to build so i'm trying to set up compilation firewalls. Now I could sprinkle pimpls or pure interfaces following my intuition but that d...
Halflength asked 8/4, 2013 at 7:18

4

Solved

Is it somehow possible, to accomplish the following: x.hpp - this file is included by many other classes class x_impl; //forward declare class x { public: //methods... private: x_impl* impl_;...
Larcenous asked 6/11, 2012 at 17:51

2

Solved

I've been trying to wrap my head around how move semantics in C++11 are supposed to work, and I'm having a good deal of trouble understanding what conditions a moved-from object needs to satisfy. L...
Holzman asked 23/8, 2012 at 15:23

1

Solved

I found this construct in some code. Is there any benefit to have a private static class implement A? This reminded me of the Pimpl idiom in C++. Is there any benefit to using the Pimpl idiom in ...
Midnight asked 10/8, 2012 at 5:48

3

Solved

I come from a C# background and have recently started learning C++. One of the things I've encountered is the pimpl idiom. I've done C# development for some large firms, but never came across it. ...
Demarcusdemaria asked 26/4, 2012 at 17:44

1

Solved

// main_pimpl_sample.cpp #include "pimpl_sample.hpp" using namespace std; int main() { pimpl_sample p; return 0; } // pimpl_sample.cpp #include "pimpl_sample.hpp" struct pimpl_sample::impl...
Bakst asked 23/12, 2011 at 18:59

2

Solved

First read Herb's Sutters GotW posts concerning pimpl in C++11: GotW #100: Compilation Firewalls (Difficulty: 6/10) GotW #101: Compilation Firewalls, Part 2 (Difficulty: 8/10) I'm having some t...
Cruck asked 21/12, 2011 at 19:50

3

Solved

I want to use the pimpl idiom to avoid having users of my library need our external dependencies (like boost, etc) however when my class is templated that seems to be impossible because the methods...
Flattop asked 22/10, 2011 at 8:18

4

Solved

I'm implementing several classes using the pimpl idiom and am coming across some design issues. Firstly, I've always seen pimpl done like this class Object { public: Visible(); ~Visible(); .. ...
Nicknickel asked 24/6, 2011 at 10:10

© 2022 - 2024 — McMap. All rights reserved.