summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-04-02 00:40:41 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-04-02 00:40:41 +0000
commit788c9979d9fff3f0bc7419c1ae9c0f0ff7f51ce8 (patch)
treec1391c35d0986e13e42fcb31e4a9b8951a77f8f4 /libcxx
parent0527c6207af5de565bbd77e64f953bbc785cee8d (diff)
downloadbcm5719-llvm-788c9979d9fff3f0bc7419c1ae9c0f0ff7f51ce8.tar.gz
bcm5719-llvm-788c9979d9fff3f0bc7419c1ae9c0f0ff7f51ce8.zip
This is an initial commit of constexpr support as proposed by Richard Smith. This by no means completes constexpr support. Indeed, it hardly scratches the surface. All it does is lay the foundation in <__config> and changes those few places in the library that are already using that foundation.
llvm-svn: 153856
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/__config4
-rw-r--r--libcxx/include/algorithm4
-rw-r--r--libcxx/include/random4
-rw-r--r--libcxx/include/type_traits13
4 files changed, 10 insertions, 15 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 6b290145858..7cd01dc1b55 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -384,7 +384,9 @@ template <unsigned> struct __static_assert_check {};
#endif
#ifdef _LIBCPP_HAS_NO_CONSTEXPR
-#define constexpr const
+#define _LIBCPP_CONSTEXPR
+#else
+#define _LIBCPP_CONSTEXPR constexpr
#endif
#ifndef __has_feature
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index f9c6843a60a..68e989a0be1 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -2712,8 +2712,8 @@ public:
result_type operator()();
- static constexpr result_type min() {return _Min;}
- static constexpr result_type max() {return _Max;}
+ static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
friend __rs_default __rs_get();
};
diff --git a/libcxx/include/random b/libcxx/include/random
index 02ea9b63011..7099af5ea86 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -3374,9 +3374,9 @@ public:
static const result_type _Max = 0xFFFFFFFFu;
_LIBCPP_INLINE_VISIBILITY
- static constexpr result_type min() { return _Min;}
+ static _LIBCPP_CONSTEXPR result_type min() { return _Min;}
_LIBCPP_INLINE_VISIBILITY
- static constexpr result_type max() { return _Max;}
+ static _LIBCPP_CONSTEXPR result_type max() { return _Max;}
// constructors
explicit random_device(const string& __token = "/dev/urandom");
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 13129f31d66..f68ed6dd29a 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -163,22 +163,15 @@ struct __two {char _[2];};
template <class _Tp, _Tp __v>
struct _LIBCPP_VISIBLE integral_constant
{
- static constexpr _Tp value = __v;
+ static _LIBCPP_CONSTEXPR const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant type;
_LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr
-#endif
- operator value_type()
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
- const
-#endif
- {return value;}
+ _LIBCPP_CONSTEXPR operator value_type() const {return value;}
};
template <class _Tp, _Tp __v>
-constexpr _Tp integral_constant<_Tp, __v>::value;
+_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
OpenPOWER on IntegriCloud