returning std::string/std::list from dll

前端 未结 4 2037
轻奢々
轻奢々 2020-12-02 22:03

Short question.

I just got a dll I\'m supposed to interface with. Dll uses crt from msvcr90D.dll (notice D), and returns std::strings, std::lists, and boost::shared_

4条回答
  •  被撕碎了的回忆
    2020-12-02 22:28

    For std::string you can return using c_str. In the case of more complicated stuff, an option can be something like

    class ContainerValueProcessor
        {
        public:
             virtual void operator()(const trivial_type& value)=0;
        };
    

    Then (assuming you want to use std::list), you can use an interface

    class List
        {
        public:
            virtual void processItems(ContainerValueProcessor&& proc)=0;
        };
    

    Notice that List can now be implemented by any container.

提交回复
热议问题