admin管理员组

文章数量:1122832

I am using a C++ std::variant with around 100 structs as possible choices. This type is used throughout my application and compile times tend to point to the instantiation and generation of various std::variant methods: e.g.

Wall Duration 18,560.314 ms
Args
detail  
"std::__variant_detail::__dtor.......

Of course there are also 100's to TU's that need this definition, so my compile times are getting quite high.

With templates I'm familiar with instantiating the template in a TU for example

template class MyClass<XXX>;

Can I do a similar thing for the variant? How do I make other TU's depend on these symbols being linked in? Can I do this in a Precompiled header perhaps?

本文标签: cPrecompile stdvariant instantiationStack Overflow