Forward declaration of std::wstring

前端 未结 5 1968
忘了有多久
忘了有多久 2021-02-05 08:00
// This is a header file.

class MyClass; // It can be forward declared because the function uses reference.
// However, how can I do forward declaraion about std::wstri         


        
5条回答
  •  时光说笑
    2021-02-05 08:09

    You can't forward declare std::wstring in a conforming implementation, not because it is a typedef for a template specialization or that there is any possibility that it has an unknown number of template arguments (it doesn't; these are strictly specified) but because there is a constraint on conforming programs that prohibits them from adding any declarations or definitions to the std namespace other than explicit specializations of standard templates which are specialized on a user-defined type.

    This constraint is stated in 17.4.3.1 [lib.reserved.names] / 1. There is no exception for forward declarations of std::wstring, you must #include to make a declaration std::wstring available in a conforming way.

提交回复
热议问题