Skip to content

Instantly share code, notes, and snippets.

@catchouli
Created June 18, 2015 19:30
Show Gist options
  • Save catchouli/fe044cb5c51d3122d42a to your computer and use it in GitHub Desktop.
Save catchouli/fe044cb5c51d3122d42a to your computer and use it in GitHub Desktop.
pimpl - dont forget your copy constructors and shit
#pragma once
class SomeClass
{
public:
SomeClass();
~SomeClass();
SomeClass(const SomeClass&);
SomeClass& SomeClass(const SomeClass&);
private:
struct Impl;
Impl* m_impl;
};
#include "header.hpp"
#include <Windows.h>
struct SomeClass::Impl
{
Impl() : m_someHandle(INVALID_HANDLE) {}
HANDLE m_someHandle;
};
// Use a smart pointer if possible
// And dont forget your copy or move construction/assignment
SomeClass()
: m_impl(new Impl) {}
~SomeClass()
{
delete m_impl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment