Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-06-24 13:39:30 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:52:30 +0300
commitf2aa6313315d27176ca3163f19c8fbe3e7919f5c (patch)
treee8a7354c08a86a6daeb99be6bcc604ba94720598 /base
parent9e2c0b978e26d5b668fa36c3a01fac79913932db (diff)
Replaced boost’s STATIC_ASSERT with a C++11 one.
Diffstat (limited to 'base')
-rw-r--r--base/base.hpp7
-rw-r--r--base/bits.hpp4
-rw-r--r--base/cache.hpp3
-rw-r--r--base/math.hpp8
-rw-r--r--base/string_utils.cpp4
5 files changed, 11 insertions, 15 deletions
diff --git a/base/base.hpp b/base/base.hpp
index f1c02b7f13..08caa162ec 100644
--- a/base/base.hpp
+++ b/base/base.hpp
@@ -1,7 +1,6 @@
#pragma once
#include "std/stdint.hpp"
-#include "std/static_assert.hpp"
#if defined(DEBUG) || defined(_DEBUG) || defined(NRELEASE) || defined(QT_DEBUG)
#define MY_DEBUG_DEFINED 1
@@ -16,10 +15,8 @@
#define MY_RELEASE_DEFINED 0
#endif
-// Either Debug or Release should be defined, but not both.
-STATIC_ASSERT(!(MY_DEBUG_DEFINED && MY_RELEASE_DEFINED));
-STATIC_ASSERT(MY_DEBUG_DEFINED || MY_RELEASE_DEFINED);
-
+static_assert(!(MY_DEBUG_DEFINED && MY_RELEASE_DEFINED), "Either Debug or Release should be defined, but not both.");
+static_assert(MY_DEBUG_DEFINED || MY_RELEASE_DEFINED, "Either Debug or Release should be defined, but not both.");
// #define DEBUG macro, which should be used with #ifdef.
#if !MY_RELEASE_DEFINED
diff --git a/base/bits.hpp b/base/bits.hpp
index 26ad241d81..8291321ae9 100644
--- a/base/bits.hpp
+++ b/base/bits.hpp
@@ -84,13 +84,13 @@ namespace bits
template <typename T> inline typename make_unsigned<T>::type ZigZagEncode(T x)
{
- STATIC_ASSERT(is_signed<T>::value);
+ static_assert(is_signed<T>::value, "Type should be signed");
return (x << 1) ^ (x >> (sizeof(x) * 8 - 1));
}
template <typename T> inline typename make_signed<T>::type ZigZagDecode(T x)
{
- STATIC_ASSERT(is_unsigned<T>::value);
+ static_assert(is_unsigned<T>::value, "Type should be unsigned.");
return (x >> 1) ^ -static_cast<typename make_signed<T>::type>(x & 1);
}
diff --git a/base/cache.hpp b/base/cache.hpp
index 3352534f34..16f70ef139 100644
--- a/base/cache.hpp
+++ b/base/cache.hpp
@@ -18,8 +18,7 @@ namespace my
explicit Cache(uint32_t logCacheSize)
: m_Cache(new Data[1 << logCacheSize]), m_HashMask((1 << logCacheSize) - 1)
{
- STATIC_ASSERT((is_same<KeyT, uint32_t>::value ||
- is_same<KeyT, uint64_t>::value));
+ static_assert((is_same<KeyT, uint32_t>::value || is_same<KeyT, uint64_t>::value), "");
// We always use cache with static constant. So debug assert is enough here.
ASSERT_GREATER ( logCacheSize, 0, () );
diff --git a/base/math.hpp b/base/math.hpp
index b4900db52f..1015825082 100644
--- a/base/math.hpp
+++ b/base/math.hpp
@@ -26,10 +26,10 @@ template <typename T> inline T Abs(T x)
template <typename TFloat>
bool AlmostEqualULPs(TFloat x, TFloat y, unsigned int maxULPs = 256)
{
- STATIC_ASSERT(is_floating_point<TFloat>::value);
- STATIC_ASSERT(numeric_limits<TFloat>::is_iec559);
- STATIC_ASSERT(!numeric_limits<TFloat>::is_exact);
- STATIC_ASSERT(!numeric_limits<TFloat>::is_integer);
+ static_assert(is_floating_point<TFloat>::value, "Only floating point is supported.");
+ static_assert(numeric_limits<TFloat>::is_iec559, "Only floating point is supported.");
+ static_assert(!numeric_limits<TFloat>::is_exact, "Only floating point is supported.");
+ static_assert(!numeric_limits<TFloat>::is_integer, "Only floating point is supported.");
// Make sure maxUlps is non-negative and small enough that the
// default NaN won't compare as equal to anything.
diff --git a/base/string_utils.cpp b/base/string_utils.cpp
index 6f7a019088..933763f215 100644
--- a/base/string_utils.cpp
+++ b/base/string_utils.cpp
@@ -119,8 +119,8 @@ namespace
char ascii_to_lower(char in)
{
char const diff = 'z' - 'Z';
- STATIC_ASSERT(diff == 'a' - 'A');
- STATIC_ASSERT(diff > 0);
+ static_assert(diff == 'a' - 'A', "");
+ static_assert(diff > 0, "");
if (in >= 'A' && in <= 'Z')
return (in + diff);