Fix MSVC "secure" warnings instead of (unsuccessfully) trying to disable them.
This commit is contained in:
parent
0802941d4f
commit
f211e313e2
27
format.h
27
format.h
@ -37,6 +37,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -54,16 +55,23 @@
|
|||||||
# define FMT_NOEXCEPT(expr)
|
# define FMT_NOEXCEPT(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Disable MSVC "secure" warnings.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable: 4996)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
template <typename T>
|
||||||
|
inline stdext::checked_array_iterator<T*>
|
||||||
|
CheckIterator(T *ptr, std::size_t size) {
|
||||||
|
return stdext::checked_array_iterator<T*>(ptr, size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
inline T *CheckIterator(T *ptr, std::size_t) {
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
// A simple array for POD types with the first SIZE elements stored in
|
// A simple array for POD types with the first SIZE elements stored in
|
||||||
// the object itself. It supports a subset of std::vector's operations.
|
// the object itself. It supports a subset of std::vector's operations.
|
||||||
template <typename T, std::size_t SIZE>
|
template <typename T, std::size_t SIZE>
|
||||||
@ -123,7 +131,7 @@ template <typename T, std::size_t SIZE>
|
|||||||
void Array<T, SIZE>::Grow(std::size_t size) {
|
void Array<T, SIZE>::Grow(std::size_t size) {
|
||||||
capacity_ = (std::max)(size, capacity_ + capacity_ / 2);
|
capacity_ = (std::max)(size, capacity_ + capacity_ / 2);
|
||||||
T *p = new T[capacity_];
|
T *p = new T[capacity_];
|
||||||
std::copy(ptr_, ptr_ + size_, p);
|
std::copy(ptr_, ptr_ + size_, CheckIterator(p, capacity_));
|
||||||
if (ptr_ != data_)
|
if (ptr_ != data_)
|
||||||
delete [] ptr_;
|
delete [] ptr_;
|
||||||
ptr_ = p;
|
ptr_ = p;
|
||||||
@ -1573,9 +1581,4 @@ void BasicFormatter<Char>::DoFormat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore MSVC "secure" warnings.
|
|
||||||
#ifdef FMT_RESTORE_SECURE_WARNINGS
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // FORMAT_H_
|
#endif // FORMAT_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user