Files
clang-p2996/libc/utils/CPP/Limits.h
Michael Jones 1d02a8bcd3 [libc] fix string conversion tests for windows
There were some copy paste errors as well as some oddities around how
windows handles the difference between long and long long types. This
change fixes those.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108591
2021-08-24 18:06:21 +00:00

60 lines
1.7 KiB
C++

//===-- A self contained equivalent of std::limits --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_UTILS_CPP_LIMITS_H
#define LLVM_LIBC_UTILS_CPP_LIMITS_H
#include <limits.h>
namespace __llvm_libc {
namespace cpp {
template <class T> class NumericLimits {
public:
static constexpr T max();
static constexpr T min();
};
// TODO: Add NumericLimits specializations as needed for new types.
template <> class NumericLimits<int> {
public:
static constexpr int max() { return INT_MAX; }
static constexpr int min() { return INT_MIN; }
};
template <> class NumericLimits<unsigned int> {
public:
static constexpr unsigned int max() { return UINT_MAX; }
static constexpr unsigned int min() { return 0; }
};
template <> class NumericLimits<long> {
public:
static constexpr long max() { return LONG_MAX; }
static constexpr long min() { return LONG_MIN; }
};
template <> class NumericLimits<unsigned long> {
public:
static constexpr unsigned long max() { return ULONG_MAX; }
static constexpr unsigned long min() { return 0; }
};
template <> class NumericLimits<long long> {
public:
static constexpr long long max() { return LLONG_MAX; }
static constexpr long long min() { return LLONG_MIN; }
};
template <> class NumericLimits<unsigned long long> {
public:
static constexpr unsigned long long max() { return ULLONG_MAX; }
static constexpr unsigned long long min() { return 0; }
};
} // namespace cpp
} // namespace __llvm_libc
#endif // LLVM_LIBC_UTILS_CPP_LIMITS_H