6 ms·
Following this rule, maybe it's time to add a shorthand for std::unique_ptr<> to c++ already. I'm not really a fan of asterixes or ampersands either but 17 char
by Too 10y ago
Following this rule, maybe it's time to add a shorthand for std::unique_ptr<> to c++ already. I'm not really a fan of asterixes or ampersands either but 17 characters, 5 of them requiring shift modifier, for something you write that often quickly becomes annoying.
- alfanick 10y agoUsually I define new types, when I use them a lot like: class Something { typedef std::unique_ptr<Something> unique; typedef std::shared_ptr<Something> shared; typedef std::weak_ptr<Something> weak; }; // ... // later in the code Something::unique a; // instead of std::unique_ptr<Something> a;
- eropple 10y agoThat's a neat way of handling it. I wouldn't have considered it. I think I'm gonna steal it.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- CyberDildonics 10y agotemplate<class T> using unq = std::unique_ptr<T>; This is a start, then I usually define specific types from there.