Make headers compatible with C++11
Remove is_signed_v and CTAD for std::array as they are in C++17 Remove remove_cv_t, remove_pointer_t, and make_unsigned_t as they are in C++14 Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
9ca7f861cf
commit
02b0ff39d7
@ -16,10 +16,10 @@ class IptcData;
|
||||
/// @brief Helper class, has methods to deal with %Photoshop "Information Resource Blocks" (IRBs).
|
||||
struct EXIV2API Photoshop {
|
||||
// Todo: Public for now
|
||||
static constexpr std::array irbId_{"8BIM", "AgHg", "DCSR", "PHUT"}; //!< %Photoshop IRB markers
|
||||
static constexpr auto ps3Id_ = "Photoshop 3.0\0"; //!< %Photoshop marker
|
||||
static constexpr uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
|
||||
static constexpr uint16_t preview_ = 0x040c; //!< %Photoshop preview marker
|
||||
static constexpr std::array<const char*, 4> irbId_{"8BIM", "AgHg", "DCSR", "PHUT"}; //!< %Photoshop IRB markers
|
||||
static constexpr auto ps3Id_ = "Photoshop 3.0\0"; //!< %Photoshop marker
|
||||
static constexpr uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
|
||||
static constexpr uint16_t preview_ = 0x040c; //!< %Photoshop preview marker
|
||||
|
||||
/// @brief Checks an IRB
|
||||
/// @param pPsData Existing IRB buffer. It is expected to be of size 4.
|
||||
|
||||
@ -263,7 +263,7 @@ struct ContainerStorage {
|
||||
|
||||
using const_iterator = typename container::const_iterator;
|
||||
|
||||
using value_type = std::remove_cv_t<typename container::value_type>;
|
||||
using value_type = typename std::remove_cv<typename container::value_type>::type;
|
||||
|
||||
/*!
|
||||
* @throw std::out_of_range when end is larger than the container's
|
||||
@ -324,7 +324,7 @@ struct ContainerStorage {
|
||||
*/
|
||||
template <typename storage_type>
|
||||
struct PtrSliceStorage {
|
||||
using value_type = std::remove_cv_t<std::remove_pointer_t<storage_type>>;
|
||||
using value_type = typename std::remove_cv<typename std::remove_pointer<storage_type>::type>::type;
|
||||
using iterator = value_type*;
|
||||
using const_iterator = const value_type*;
|
||||
|
||||
@ -423,7 +423,7 @@ struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, con
|
||||
|
||||
using const_iterator = typename container::const_iterator;
|
||||
|
||||
using value_type = std::remove_cv_t<typename container::value_type>;
|
||||
using value_type = typename std::remove_cv<typename container::value_type>::type;
|
||||
|
||||
/*!
|
||||
* @brief Construct a slice of the container `cont` starting at `begin`
|
||||
@ -476,7 +476,7 @@ struct Slice<const container> : public Internal::ConstSliceBase<Internal::Contai
|
||||
|
||||
using const_iterator = typename container::const_iterator;
|
||||
|
||||
using value_type = std::remove_cv_t<typename container::value_type>;
|
||||
using value_type = typename std::remove_cv<typename container::value_type>::type;
|
||||
|
||||
Slice(const container& cont, size_t begin, size_t end) :
|
||||
Internal::ConstSliceBase<Internal::ContainerStorage, const container>(cont, begin, end) {
|
||||
|
||||
@ -1261,7 +1261,8 @@ class ValueType : public Value {
|
||||
//! Utility for toInt64, toUint32, etc.
|
||||
template <typename I>
|
||||
inline I rational_to_integer_helper(size_t n) const {
|
||||
auto&& [a, b] = value_.at(n);
|
||||
auto a = value_.at(n).first;
|
||||
auto b = value_.at(n).second;
|
||||
|
||||
// Protect against divide-by-zero.
|
||||
if (b <= 0) {
|
||||
@ -1269,16 +1270,16 @@ class ValueType : public Value {
|
||||
}
|
||||
|
||||
// Check for integer overflow.
|
||||
if (std::is_signed_v<I> == std::is_signed_v<decltype(a)>) {
|
||||
if (std::is_signed<I>::value == std::is_signed<decltype(a)>::value) {
|
||||
// conversion does not change sign
|
||||
const auto imin = std::numeric_limits<I>::min();
|
||||
const auto imax = std::numeric_limits<I>::max();
|
||||
if (imax < b || a < imin || imax < a) {
|
||||
return 0;
|
||||
}
|
||||
} else if (std::is_signed_v<I>) {
|
||||
} else if (std::is_signed<I>::value) {
|
||||
// conversion is from unsigned to signed
|
||||
const auto imax = std::make_unsigned_t<I>(std::numeric_limits<I>::max());
|
||||
const auto imax = typename std::make_unsigned<I>::type(std::numeric_limits<I>::max());
|
||||
if (imax < b || imax < a) {
|
||||
return 0;
|
||||
}
|
||||
@ -1289,8 +1290,8 @@ class ValueType : public Value {
|
||||
return 0;
|
||||
}
|
||||
// Inputs are not negative so convert them to unsigned.
|
||||
const auto a_u = std::make_unsigned_t<decltype(a)>(a);
|
||||
const auto b_u = std::make_unsigned_t<decltype(b)>(b);
|
||||
const auto a_u = typename std::make_unsigned<decltype(a)>::type(a);
|
||||
const auto b_u = typename std::make_unsigned<decltype(b)>::type(b);
|
||||
if (imax < b_u || imax < a_u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user