Skip to content

Instantly share code, notes, and snippets.

@tablatronix
Created February 20, 2018 18:47
Show Gist options
  • Save tablatronix/2e1ab49ea4944654091da56cca501494 to your computer and use it in GitHub Desktop.
Save tablatronix/2e1ab49ea4944654091da56cca501494 to your computer and use it in GitHub Desktop.
// .h
#ifdef whatnot
std::unique_ptr<classA> theclass;
#else
std::unique_ptr<classB> theclass;
#endif
// .cpp
// How can I avoid using the actual classnames here
#ifdef whatnot
theclass.reset(new classA(blargh));
#else
theclass.reset(new classB(blargh));
#endif
@tablatronix
Copy link
Author

tablatronix commented Feb 20, 2018

using

#ifdef whatnot
using classX = classA;
#else
using classX = classB;
#endif

std::unique_ptr<classX> theclass;
theclass.reset(new classX(blargh));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment