diff options
author | Sergey Yershov <syershov@maps.me> | 2017-01-13 13:48:35 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2017-01-13 19:09:10 +0300 |
commit | b449b488587ed836adad64a198f1cf8707714c74 (patch) | |
tree | 2379d851e2ba59039cd0b56abd3f0a559f276fbe /base | |
parent | f7efe4fd53d99a2d0b178abc24ff0ad2c2a0dcb5 (diff) |
Fix warnings.
Diffstat (limited to 'base')
-rw-r--r-- | base/checked_cast.hpp | 20 | ||||
-rw-r--r-- | base/condition.cpp | 3 | ||||
-rw-r--r-- | base/stl_iterator.hpp | 11 |
3 files changed, 32 insertions, 2 deletions
diff --git a/base/checked_cast.hpp b/base/checked_cast.hpp new file mode 100644 index 0000000000..363840c785 --- /dev/null +++ b/base/checked_cast.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "base/assert.hpp" + +namespace base +{ +template <typename ReturnType, typename ParameterType> +ReturnType checked_cast(ParameterType v) +{ + CHECK_EQUAL(static_cast<ParameterType>(static_cast<ReturnType>(v)), v, ()); + return static_cast<ReturnType>(v); +} + +template <typename ReturnType, typename ParameterType> +ReturnType asserted_cast(ParameterType v) +{ + ASSERT_EQUAL(static_cast<ParameterType>(static_cast<ReturnType>(v)), v, ()); + return static_cast<ReturnType>(v); +} +} // namespace base diff --git a/base/condition.cpp b/base/condition.cpp index 1082a04346..2be49f0e27 100644 --- a/base/condition.cpp +++ b/base/condition.cpp @@ -8,6 +8,7 @@ #include <cerrno> #include <cstdint> +#include <limits> namespace threads { @@ -47,7 +48,7 @@ namespace threads bool Condition::Wait(unsigned ms) { - if (ms == -1) + if (ms == std::numeric_limits<unsigned>::max()) { Wait(); return false; diff --git a/base/stl_iterator.hpp b/base/stl_iterator.hpp index a409f08b5f..4637dc9704 100644 --- a/base/stl_iterator.hpp +++ b/base/stl_iterator.hpp @@ -1,6 +1,15 @@ #pragma once -#include <boost/iterator/iterator_facade.hpp> +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#endif + +#include "3party/boost/boost/iterator/iterator_facade.hpp" + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif namespace detail { |