In our codebase we use std::variant<std::shared_ptr<SomeClass>, ...>
a lot.
That obviously requires a lot of writing. How to make a template?
template <class... T>
using VarSP = std::variant<std::shared_ptr<???>>;
Where should T
go in the above snippet? The desired behavior should be:
VarSP<Foo, Bar, Baz> // std::variant<std::shared_ptr<Foo>, std::shared_ptr<Bar>, std::shared_ptr<Baz>>
template <typename... T>
using VarSP = std::variant<std::shared_ptr<T>...>;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.