1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Fix -Wtype-limits

This commit is contained in:
Alexey Antipovsky
2020-11-10 18:23:21 +00:00
parent f4a6294c95
commit 0e29b0b0f9
11 changed files with 75 additions and 19 deletions

43
utils/common/checks.h Normal file
View File

@ -0,0 +1,43 @@
/* Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef UTILS_COMMON_CHECKS_H
#define UTILS_COMMON_CHECKS_H
#include <type_traits>
namespace utils {
template <typename T>
typename std::enable_if<std::is_unsigned<T>::value, bool>::type is_nonnegative(T)
{ return true; };
template <typename T>
typename std::enable_if<std::is_signed<T>::value, bool>::type is_nonnegative(T v)
{ return v >= 0; };
template <typename T>
typename std::enable_if<std::is_unsigned<T>::value, bool>::type is_negative(T)
{ return false; };
template <typename T>
typename std::enable_if<std::is_signed<T>::value, bool>::type is_negative(T v)
{ return v < 0; };
} // namespace utils
#endif // UTILS_COMMON_CHECKS_H