Back
Close

Modern C++ idoms and recipes

meshell
14.3K views

Any type

C++17 added the std::any type to the standard library. It is designed to hold variables of any type and provides methods for type-safe inspection and access.

Exercise

Refactor the following code to use std::any.
#include <typeindex>
#include <vector>
#include <string>
#include <iostream>
struct element
{
void* elem;
std::type_index type;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants