Safely use containers in C++ library interface

前端 未结 4 995
予麋鹿
予麋鹿 2021-02-02 00:28

When designing a C++ library, I read it is bad practice to include standard library containers like std::vector in the public interface (see e.g. Implications of us

4条回答
  •  醉酒成梦
    2021-02-02 00:58

    If you are using C++11, you can use cppcomponents. https://github.com/jbandela/cppcomponents

    This will allow you to use among other things std::vector as a parameter or return value across Dll/or .so files created using different compilers or standard libraries. Take a look at my answer to a similar question for an example Passing reference to STL vector over dll boundary

    Note for the example, you need to add a CPPCOMPONENTS_REGISTER(ImplementFiles) after the CPPCOMPONENTS_DEFINE_FACTORY() statement

提交回复
热议问题