Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <type_traits>
- #include <variant>
- #include <vector>
- #include <iostream>
- #include <string>
- using Var1 = std::variant<uint32_t, float, char>;
- using Var2 = std::variant<char, double>;
- template< class ... TArgs> void func(TArgs && ... args) {
- auto pr = [](auto && item) {
- std::cout << "type: " << typeid(item).name() << std::endl;
- std::visit([](auto && arg) {
- std::cout << "item value: '" << arg << "', type: " << typeid(arg).name() << std::endl;
- },
- item );
- };
- (pr(args) , ...);
- };
- int main () {
- Var1 oObj1(0.1f);
- Var2 oObj2('c');
- func(oObj1, oObj2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement