Reputation: 38025
I am no longer able to build my C++ project after coming back to it after a while (I've since updated macOS and Xcode), either from Xcode or by calling clang on the command line. I am getting an error on every use of std::shared_ptr::make_shared in my code. I want to emphasize this used to compile and run fine and I don't understand what has changed. Perhaps updating xcode broke my toolchain somehow.
I have reproduced the problem in some very trivial code that I believe should compile fine:
#include <string>
#include <memory>
class test_c {
private:
std::string str_;
public:
test_c(std::string str__) : str_(str__) { }
};
std::string test_s = "test";
auto test = std::shared_ptr<test_c>::make_shared(test_s);
The errors look like this:
$ clang -std=c++14 test.cpp
test.cpp:10:38: error: no member named 'make_shared' in 'std::__1::shared_ptr<test_c>'
auto test = std::shared_ptr<test_c>::make_shared(test_s);
~~~~~~~~~~~~~~~~~~~~~~~~~^
1 error generated.
Upvotes: 2
Views: 425
Reputation: 1025
I can't find any way to call make_shared
as a static method at all. Also checked your code in other in older versions of Clang. Doesn't seem that it can work...
Maybe just:
auto test = std::make_shared<test_c>(test_s);
UPD Wait. Indeed it worked in in clang of version 9. Looks it really was updated to disable this feature... Not working in v10.
Upvotes: 1