Mortennobel
Mortennobel

Reputation: 3471

Is there a preprocessor directive for detecting C++11 Standard library?

Is it possible to determine if C++ standard library has C++11 support using a preprocessor directive?

I'm currently working on a project which uses the C++11 language dialect, but with the a C++ standard library without C++11 support (I need this to be able to link with non C++11 libraries).

I'm aware of that I can test of C++11 support using the #if __cplusplus >= 201103L, but in my case this will evaluate to true. I need to know about the C++ standard library support for C++11.

Upvotes: 6

Views: 1179

Answers (2)

TemplateRex
TemplateRex

Reputation: 70506

Testing for features is an active research direction for the Standard Committee going towards the next C++14 Standard (and beyond that). There is a Study Group 10 with its own freely accessible mailinglist where current development is being discussed. For the next meeting, this N3694 working paper has been submitted.

Upvotes: 4

Mortennobel
Mortennobel

Reputation: 3471

My problem was on the iOS platform where the choice of C++ standard library was between libstd++ (GNU C++ standard library) and libc++ (LLVM C++ standard library with C++11 support). I ended up using the _GLIBCXX_. The complete code ended up being:

#ifndef _GLIBCXX_
template <class T>
T&& move (T& arg) noexcept {
    return static_cast<T&&>(arg);
}
#endif

Upvotes: 3

Related Questions