Skip to content

Instantly share code, notes, and snippets.

@jeremyroman
Last active June 17, 2020 23:00
Show Gist options
  • Save jeremyroman/0b31f7f91ee310c086cd48294990361e to your computer and use it in GitHub Desktop.
Save jeremyroman/0b31f7f91ee310c086cd48294990361e to your computer and use it in GitHub Desktop.
class AssociatedFrobnicator : public base::SupportsUserData::Data {
public:
Frobnicator* frobnicator() const { return frobnicator_; }
void set_frobnicator(Frobnicator* frobnicator) const { frobnicator_ = frobnicator; }
private:
Frobnicator* frobnicator_;
};
base::SupportsUserData::Data* data;
static_cast<AssociatedFrobnicator*>(data)->set_frobnicator(new_frobnicator);
std::any& data;
any_cast<Frobnicator*&>(data) = new_frobnicator;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment