rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.12k stars 430 forks source link

Is there a way to create variant of std::vector #300

Open rovingstar123 opened 3 years ago

rovingstar123 commented 3 years ago

Hello,

Is there a way to create a variant of std::vector? explained by following code:

rttr::variant createVectorVariant(const rttr::type& vectorType)
{
    if(vectorType == rttr::type::get<std::vector<int>>())
    {
        return rttr::variant(std::vector<int>());
    }
    else if(vectorType == rttr::type::get<std::vector<float>>())
    {
        return rttr::variant(std::vector<float>());
    }
    else if ...
    //endless type checks, and vectorType.create() doesn't work
    //is there an actual way to implement this function?
}