Visual c++ 2015 cross platform mobile (android/ios) shared_ptr question


  • I am newbie in VS2015.

    I have tried to compile following test source which has shared_ptr.

    #include <string>
    #include <iostream>
    #include <memory>

    using namespace std;

    namespace ruby_base
        class baseApi
            virtual ~baseApi() {}

            static std::shared_ptr<baseApi> create_api();

            virtual std::string get_text() = 0;
            virtual void set_text(const std::string & text) = 0;

    and it gave me following error.

    baseApi.hpp(19,15): error : no type named 'shared_ptr' in namespace 'std'

    so i have checked whether std has shared_ptr or not. and it really doesn't have shared_ptr (but it has auto_ptr -_-)

    So now i have created simple MFC application and have checked whether it has shared_ptr. and it has shared_ptr.

    My quetion is why CrossPlatform Shared C++ library project doesn't support shared_ptr?

    How can i use shared_ptr in mobile shared library project? If i can't, Is there any substitute?

    Saturday, December 12, 2015 4:09 AM


All replies

  • i have solved the problem.

    There is c++ language standard selection setting.


     -> c/c++

       --> language

          --> c++ language standard

             --> change default c++ standard to c++11

    I think default setting was C++03(-std=c++98).

    which is very old stl library (made in 1998), so it doesn't have shared_ptr.

    Monday, December 14, 2015 7:30 AM
  • Hi visual_study777,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    I'm glad that you have resolved your problem. Thanks for sharing your solution here and please mark your reply as answer, which is benefit to other communities who has the same problem.

    If any question about Visual Studio IDE, please feel free to come back to our forum.

    Best Regards,

    Monday, December 14, 2015 10:11 AM