Created
March 27, 2020 16:22
-
-
Save toddlipcon/a5be097a734f7abda08a35e953302010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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