Skip to content

Commit 63c62cc

Browse files
ehsancjihrig
authored andcommitted
src: Only use TR1 type_traits on OSX<10.9
Mac OSX 10.9 has switched to using libc++ by default. libc++ provides a C++11 <type_traits> implementation, so we only need to use the TR1 version when targetting OSX 10.8 or 10.7. PR-URL: #7778 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 8f51e36 commit 63c62cc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/util.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
#include <stdio.h>
1212
#include <stdlib.h>
1313

14-
#ifdef __APPLE__
14+
// OSX 10.9 defaults to libc++ which provides a C++11 <type_traits> header.
15+
#if defined(__APPLE__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090
16+
#define USE_TR1_TYPE_TRAITS
17+
#endif
18+
19+
#ifdef USE_TR1_TYPE_TRAITS
1520
#include <tr1/type_traits> // NOLINT(build/c++tr1)
1621
#else
1722
#include <type_traits> // std::remove_reference
@@ -31,7 +36,7 @@ NO_RETURN void Abort();
3136
NO_RETURN void Assert(const char* const (*args)[4]);
3237
void DumpBacktrace(FILE* fp);
3338

34-
#ifdef __APPLE__
39+
#ifdef USE_TR1_TYPE_TRAITS
3540
template <typename T> using remove_reference = std::tr1::remove_reference<T>;
3641
#else
3742
template <typename T> using remove_reference = std::remove_reference<T>;

0 commit comments

Comments
 (0)