paulm
paulm

Reputation: 5882

How to use make_unique in clang 3.4?

Using Travis-CI I'm trying to build a C++ project that uses std::make_unique. However I get a build error:

no member named 'make_unique' in namespace 'std'
            mFiles.emplace_back(std::make_unique<File>(*this, rec));

I have included memory, and this code compiles in VS2013 and gcc 4.8 with -std=c++14. If I use this flag in clang 3.4 I get an error:

error: invalid value 'c++14' in '-std=c++14'

According the the clang docs:

http://clang.llvm.org/cxx_status.html

I should be using -std=c++1y but this still yeilds the same no member named 'make_unique' in namespace 'std'. So how do I get it to work?

Upvotes: 4

Views: 5451

Answers (1)

Vittorio Romeo
Vittorio Romeo

Reputation: 93274

This does not depend on the compiler, but on the standard library implementation. std::make_unique is not a core language feature, but a library function.

Check the version of libstdc++ used by Travis.


According to the GCC 4.9 changelog, std::make_unique was introduced into libstdc++ around the time of release of GCC 4.9.

If Travis is using a version of GCC prior to 4.9, it's very probable that its libstdc++ version does not have std::make_unique yet.

Upvotes: 4

Related Questions