Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created March 27, 2020 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlipcon/a5be097a734f7abda08a35e953302010 to your computer and use it in GitHub Desktop.
Save toddlipcon/a5be097a734f7abda08a35e953302010 to your computer and use it in GitHub Desktop.
#include <boost/optional.hpp>
using namespace boost;
class C {
public:
C() :
data_(initial_data_) {
}
~C() {
if (data_ != initial_data_) {
delete[] data_;
}
}
private:
uint8_t initial_data_[4];
uint8_t* data_;
};
void foo() {
optional<C> x;
for (int i = 0; i < 2; i++) {
x.emplace();
x.reset();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment