问题
It is used in libc++ on many template types such as tuple_element
, tuple
, etc.
As far as I can tell there is no public documentation of what it does other than the commit message introducing it and this unit test in the clang project.
回答1:
This attribute allows the ELF visibility of a type and (presumably) its vague linkage objects (vtable, typeinfos) to be controlled separately from the visibility of functions and data members of the type.
This allows typeinfos and the vtable for, say, explicit instantiations of a templated polymorphic type to be located centrally without forcing default visibility on for the type's private static data members as well -- exporting symbols for things that nobody will ever actually access across a library boundary is wasteful of runtime and symbol table space when working with shared libraries.
来源:https://stackoverflow.com/questions/28437772/what-does-clangs-type-visibility-attribute-do-and-when-should-one-use-it