Comment on Grim C++ Tales from the Crypt: The Visitor Pattern (2017)parentComments−ddalcino7yUntil C++2z rolls out with match support, you can roll your own. Nikolai Wuttke gave a lecture at MeetingCpp 2018 (https://www.youtube.com/watch?v=CELWr9roNno) that presents code that lets you do this: // Client visitor code match( thingy, [](const PurpleThingy& ) {std::cout << "purple thingy\n";}, [](const LittleThingy& ) {std::cout << "little thingy\n";}, [](const auto& ) {std::cout << "any other type\n";} ); Working example: https://coliru.stacked-crooked.com/a/dfed39bc7fcdfb01
Comments
Until C++2z rolls out with match support, you can roll your own. Nikolai Wuttke gave a lecture at MeetingCpp 2018 (https://www.youtube.com/watch?v=CELWr9roNno) that presents code that lets you do this:
Working example: https://coliru.stacked-crooked.com/a/dfed39bc7fcdfb01