Implement requested changes
Fix some of the MSVC warnings Implement C++11 integer_sequence
This commit is contained in:
parent
710d078824
commit
58991c7404
13
.travis.yml
13
.travis.yml
@ -23,13 +23,10 @@ env:
|
||||
o1F2EwFbiso0EmtzhAPs19ujiVxkLn4=
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- env: TRAVIS_EMPTY_JOB_WORKAROUND=true
|
||||
include:
|
||||
# Documentation
|
||||
- env: CXX_COMPILER=g++-6 BUILD=Doc
|
||||
- env: BUILD=Doc
|
||||
sudo: required
|
||||
compiler: gcc
|
||||
# g++ 6 on Linux with C++14
|
||||
- env: CXX_COMPILER=g++-6 BUILD=Debug STANDARD=14
|
||||
compiler: gcc
|
||||
@ -116,15 +113,9 @@ matrix:
|
||||
- env: CXX_COMPILER=g++-4.4 BUILD=Debug STANDARD=0x
|
||||
compiler: gcc
|
||||
|
||||
install:
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||
|
||||
- cd ${TRAVIS_BUILD_DIR}
|
||||
|
||||
before_script:
|
||||
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then export CXX=${CXX_COMPILER}; fi
|
||||
- ${CXX} --version
|
||||
- if [[ "${BUILD}" != "Doc" ]]; then ${CXX} --version; fi
|
||||
|
||||
script:
|
||||
- support/travis-build.py
|
||||
|
||||
@ -36,6 +36,12 @@
|
||||
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
#else
|
||||
# define FMT_GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION
|
||||
#else
|
||||
@ -557,21 +563,22 @@ struct typed_value : value<Context> {
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR basic_format_arg<Context> make_arg(const T &value);
|
||||
|
||||
#if FMT_GCC_VERSION >= 406
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#endif
|
||||
|
||||
#define FMT_MAKE_VALUE(TAG, ArgType, ValueType) \
|
||||
template <typename C> \
|
||||
FMT_CONSTEXPR typed_value<C, TAG> make_value(ArgType val) { \
|
||||
return static_cast<ValueType>(val); \
|
||||
}
|
||||
|
||||
#define FMT_MAKE_VALUE_SAME(TAG, Type) \
|
||||
template <typename C> \
|
||||
FMT_CONSTEXPR typed_value<C, TAG> make_value(Type val) { \
|
||||
return val; \
|
||||
}
|
||||
|
||||
FMT_MAKE_VALUE(bool_type, bool, int)
|
||||
FMT_MAKE_VALUE(int_type, short, int)
|
||||
FMT_MAKE_VALUE(uint_type, unsigned short, unsigned)
|
||||
FMT_MAKE_VALUE(int_type, int, int)
|
||||
FMT_MAKE_VALUE_SAME(int_type, int)
|
||||
FMT_MAKE_VALUE(uint_type, unsigned, unsigned)
|
||||
|
||||
// To minimize the number of types we need to deal with, long is translated
|
||||
@ -586,7 +593,7 @@ FMT_MAKE_VALUE(
|
||||
(sizeof(unsigned long) == sizeof(unsigned) ? uint_type : ulong_long_type),
|
||||
unsigned long, ulong_type)
|
||||
|
||||
FMT_MAKE_VALUE(long_long_type, long long, long long)
|
||||
FMT_MAKE_VALUE_SAME(long_long_type, long long)
|
||||
FMT_MAKE_VALUE(ulong_long_type, unsigned long long, unsigned long long)
|
||||
FMT_MAKE_VALUE(int_type, signed char, int)
|
||||
FMT_MAKE_VALUE(uint_type, unsigned char, unsigned)
|
||||
@ -601,8 +608,8 @@ inline typed_value<C, char_type> make_value(wchar_t val) {
|
||||
#endif
|
||||
|
||||
FMT_MAKE_VALUE(double_type, float, double)
|
||||
FMT_MAKE_VALUE(double_type, double, double)
|
||||
FMT_MAKE_VALUE(long_double_type, long double, long double)
|
||||
FMT_MAKE_VALUE_SAME(double_type, double)
|
||||
FMT_MAKE_VALUE_SAME(long_double_type, long double)
|
||||
|
||||
// Formatting of wide strings into a narrow buffer and multibyte strings
|
||||
// into a wide buffer is disallowed (https://github.com/fmtlib/fmt/pull/606).
|
||||
@ -612,28 +619,22 @@ FMT_MAKE_VALUE(cstring_type, const typename C::char_type*,
|
||||
const typename C::char_type*)
|
||||
|
||||
FMT_MAKE_VALUE(cstring_type, signed char*, const signed char*)
|
||||
FMT_MAKE_VALUE(cstring_type, const signed char*, const signed char*)
|
||||
FMT_MAKE_VALUE_SAME(cstring_type, const signed char*)
|
||||
FMT_MAKE_VALUE(cstring_type, unsigned char*, const unsigned char*)
|
||||
FMT_MAKE_VALUE(cstring_type, const unsigned char*, const unsigned char*)
|
||||
FMT_MAKE_VALUE(string_type, basic_string_view<typename C::char_type>,
|
||||
basic_string_view<typename C::char_type>)
|
||||
FMT_MAKE_VALUE_SAME(cstring_type, const unsigned char*)
|
||||
FMT_MAKE_VALUE_SAME(string_type, basic_string_view<typename C::char_type>)
|
||||
FMT_MAKE_VALUE(string_type,
|
||||
typename basic_string_view<typename C::char_type>::type,
|
||||
basic_string_view<typename C::char_type>)
|
||||
FMT_MAKE_VALUE(string_type, const std::basic_string<typename C::char_type>&,
|
||||
basic_string_view<typename C::char_type>)
|
||||
FMT_MAKE_VALUE(pointer_type, void*, const void*)
|
||||
FMT_MAKE_VALUE(pointer_type, const void*, const void*)
|
||||
FMT_MAKE_VALUE_SAME(pointer_type, const void*)
|
||||
|
||||
#if FMT_USE_NULLPTR
|
||||
FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*)
|
||||
#endif
|
||||
|
||||
#if FMT_GCC_VERSION >= 406
|
||||
// -Wuseless-cast
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
// Formatting of arbitrary pointers is disallowed. If you want to output a
|
||||
// pointer cast it to "void *" or "const void *". In particular, this forbids
|
||||
// formatting of "[const] volatile char *" which is printed as bool by
|
||||
|
||||
@ -65,8 +65,7 @@ inline fmt::internal::null<> strerror_s(char *, std::size_t, ...) {
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
FMT_FUNC format_error::~format_error() throw() {}
|
||||
FMT_FUNC system_error::~system_error() FMT_DTOR_NOEXCEPT {}
|
||||
namespace {
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# define FMT_SNPRINTF snprintf
|
||||
|
||||
@ -37,12 +37,6 @@
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
#else
|
||||
# define FMT_GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
||||
#else
|
||||
@ -63,7 +57,8 @@
|
||||
# define FMT_MSC_VER 0
|
||||
#endif
|
||||
|
||||
#if FMT_GCC_VERSION >= 406 || FMT_CLANG_VERSION
|
||||
#if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 406) || \
|
||||
FMT_CLANG_VERSION
|
||||
# pragma GCC diagnostic push
|
||||
|
||||
// Disable the warning about declaration shadowing because it affects too
|
||||
@ -81,8 +76,6 @@
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
# pragma clang diagnostic ignored "-Wpadded"
|
||||
# pragma clang diagnostic ignored "-Wgnu-statement-expression"
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||
# pragma clang diagnostic ignored "-Wglobal-constructors"
|
||||
# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
|
||||
# pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
@ -3146,7 +3139,7 @@ struct formatter<
|
||||
break;
|
||||
case internal::char_type:
|
||||
handle_char_specs(specs_, internal::char_specs_checker<decltype(eh)>(
|
||||
type_spec, eh));
|
||||
static_cast<char>(type_spec), eh));
|
||||
break;
|
||||
case internal::double_type:
|
||||
case internal::long_double_type:
|
||||
@ -3178,8 +3171,8 @@ struct formatter<
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
specs_.precision_, specs_.precision_ref, ctx);
|
||||
typedef output_range<typename FormatContext::iterator,
|
||||
typename FormatContext::char_type> range;
|
||||
visit(arg_formatter<range>(ctx, specs_),
|
||||
typename FormatContext::char_type> range_type;
|
||||
visit(arg_formatter<range_type>(ctx, specs_),
|
||||
internal::make_arg<FormatContext>(val));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
@ -52,7 +52,6 @@ class printf_precision_handler: public function<int> {
|
||||
typename std::enable_if<!std::is_integral<T>::value, int>::type
|
||||
operator()(T) {
|
||||
FMT_THROW(format_error("precision is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -194,7 +193,6 @@ class printf_width_handler: public function<unsigned> {
|
||||
typename std::enable_if<!std::is_integral<T>::value, unsigned>::type
|
||||
operator()(T) {
|
||||
FMT_THROW(format_error("width is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
@ -126,8 +126,38 @@ struct is_tuple_like {
|
||||
is_tuple_like_<T>::value && !is_range_<T>::value;
|
||||
};
|
||||
|
||||
template <size_t... Is, class Tuple, class F>
|
||||
void for_each(std::index_sequence<Is...>, Tuple &&tup, F &&f) noexcept {
|
||||
// Check for integer_sequence
|
||||
#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1910
|
||||
template <typename T, T... N>
|
||||
using integer_sequence = std::integer_sequence<T, N...>;
|
||||
template <std::size_t... N>
|
||||
using index_sequence = std::index_sequence<N...>;
|
||||
template <std::size_t N>
|
||||
using make_index_sequence = std::make_index_sequence<N>;
|
||||
#else
|
||||
template <typename T, T... N>
|
||||
struct integer_sequence {
|
||||
typedef T value_type;
|
||||
|
||||
static FMT_CONSTEXPR std::size_t size() {
|
||||
return sizeof...(N);
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t... N>
|
||||
using index_sequence = integer_sequence<std::size_t, N...>;
|
||||
|
||||
template <typename T, std::size_t N, T... Ns>
|
||||
struct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Ns...> {};
|
||||
template <typename T, T... Ns>
|
||||
struct make_integer_sequence<T, 0, Ns...> : integer_sequence<T, Ns...> {};
|
||||
|
||||
template <std::size_t N>
|
||||
using make_index_sequence = make_integer_sequence<std::size_t, N>;
|
||||
#endif
|
||||
|
||||
template <class Tuple, class F, size_t... Is>
|
||||
void for_each(index_sequence<Is...>, Tuple &&tup, F &&f) noexcept {
|
||||
using std::get;
|
||||
// using free function get<I>(T) now.
|
||||
const int _[] = {0, ((void)f(get<Is>(tup)), 0)...};
|
||||
@ -135,7 +165,7 @@ void for_each(std::index_sequence<Is...>, Tuple &&tup, F &&f) noexcept {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
FMT_CONSTEXPR std::make_index_sequence<std::tuple_size<T>::value>
|
||||
FMT_CONSTEXPR make_index_sequence<std::tuple_size<T>::value>
|
||||
get_indexes(T const &) { return {}; }
|
||||
|
||||
template <class Tuple, class F>
|
||||
|
||||
@ -54,7 +54,6 @@ inline std::tm localtime(std::time_t time) {
|
||||
return lt.tm_;
|
||||
// Too big time values may be unsupported.
|
||||
FMT_THROW(format_error("time_t value out of range"));
|
||||
return std::tm();
|
||||
}
|
||||
|
||||
// Thread-safe replacement for std::gmtime
|
||||
@ -90,7 +89,6 @@ inline std::tm gmtime(std::time_t time) {
|
||||
return gt.tm_;
|
||||
// Too big time values may be unsupported.
|
||||
FMT_THROW(format_error("time_t value out of range"));
|
||||
return std::tm();
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
configuration: Debug
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
clone_depth: 1
|
||||
|
||||
@ -32,7 +34,7 @@ before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
|
||||
- ps: cmake -G "$($env:CMAKE_GENERATOR)$($env:CMAKE_GENERATOR_SUFFIX)" -DFMT_WERROR=OFF -DFMT_PEDANTIC=ON -DCMAKE_BUILD_TYPE=Debug ..
|
||||
- ps: cmake -G "$($env:CMAKE_GENERATOR)$($env:CMAKE_GENERATOR_SUFFIX)" -DFMT_WERROR=OFF -DFMT_PEDANTIC=ON -DCMAKE_BUILD_TYPE="$($env:configuration)" ..
|
||||
|
||||
build:
|
||||
project: C:\projects\fmt\build\fmt.sln
|
||||
@ -42,7 +44,7 @@ build:
|
||||
test_script:
|
||||
- ps: |
|
||||
New-Item .\DartConfiguration.tcl -ItemType file
|
||||
ctest -C Debug -T Test
|
||||
ctest -C "$($env:configuration)" -T Test
|
||||
$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform
|
||||
$XslInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl")
|
||||
$file = $(ls Testing\*\Test.xml) | Select -first 1
|
||||
|
||||
@ -30,9 +30,8 @@ struct ValueExtractor: fmt::internal::function<T> {
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
T operator()(U) {
|
||||
FMT_NORETURN T operator()(U) {
|
||||
throw std::runtime_error(fmt::format("invalid type {}", typeid(U).name()));
|
||||
return T();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -195,39 +195,33 @@ TEST(ExpectSystemErrorTest, DoesNotGenerateUnreachableCodeWarning) {
|
||||
}
|
||||
|
||||
TEST(AssertionSyntaxTest, ExceptionAssertionBehavesLikeSingleStatement) {
|
||||
if (::testing::internal::AlwaysFalse()) {
|
||||
if (::testing::internal::AlwaysFalse())
|
||||
EXPECT_THROW_MSG(do_nothing(), std::exception, "");
|
||||
}
|
||||
|
||||
if (::testing::internal::AlwaysTrue()) {
|
||||
if (::testing::internal::AlwaysTrue())
|
||||
EXPECT_THROW_MSG(throw_exception(), std::exception, "test");
|
||||
} else {
|
||||
else
|
||||
do_nothing();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AssertionSyntaxTest, SystemErrorAssertionBehavesLikeSingleStatement) {
|
||||
if (::testing::internal::AlwaysFalse()) {
|
||||
if (::testing::internal::AlwaysFalse())
|
||||
EXPECT_SYSTEM_ERROR(do_nothing(), EDOM, "");
|
||||
}
|
||||
|
||||
if (::testing::internal::AlwaysTrue()) {
|
||||
if (::testing::internal::AlwaysTrue())
|
||||
EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, "test");
|
||||
} else {
|
||||
else
|
||||
do_nothing();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AssertionSyntaxTest, WriteAssertionBehavesLikeSingleStatement) {
|
||||
if (::testing::internal::AlwaysFalse()) {
|
||||
if (::testing::internal::AlwaysFalse())
|
||||
EXPECT_WRITE(stdout, std::printf("x"), "x");
|
||||
}
|
||||
|
||||
if (::testing::internal::AlwaysTrue()) {
|
||||
if (::testing::internal::AlwaysTrue())
|
||||
EXPECT_WRITE(stdout, std::printf("x"), "x");
|
||||
} else {
|
||||
else
|
||||
do_nothing();
|
||||
}
|
||||
}
|
||||
|
||||
// Tests EXPECT_THROW_MSG.
|
||||
|
||||
@ -822,7 +822,8 @@ TEST(UtilTest, FormatLongWindowsError) {
|
||||
const int provisioning_not_allowed = 0x80284013L /*TBS_E_PROVISIONING_NOT_ALLOWED*/;
|
||||
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0,
|
||||
provisioning_not_allowed, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
static_cast<DWORD>(provisioning_not_allowed),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
reinterpret_cast<LPWSTR>(&message), 0, 0) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user