From 4f3cab39126883a7baaf3a62af677d46083412d8 Mon Sep 17 00:00:00 2001 From: Viacheslav Kroilov Date: Sat, 5 May 2018 19:26:17 +0200 Subject: [PATCH] Fixes for windows --- epi_judge_cpp/CMakeLists.txt | 2 +- epi_judge_cpp/drawing_skyline.cc | 8 +++++--- epi_judge_cpp/rectangle_intersection.cc | 12 ++++++++---- epi_judge_cpp/test_framework/binary_tree_utils.h | 16 ++++++++++------ epi_judge_cpp/test_framework/console_color.h | 2 ++ epi_judge_cpp/test_framework/platform.h | 2 +- epi_judge_cpp_solutions/CMakeLists.txt | 2 +- epi_judge_cpp_solutions/drawing_skyline.cc | 9 ++++++--- .../rectangle_intersection.cc | 14 ++++++++++---- .../search_unknown_length_array.cc | 4 ++-- .../test_framework/binary_tree_utils.h | 16 ++++++++++------ .../test_framework/console_color.h | 2 ++ .../test_framework/platform.h | 2 +- 13 files changed, 59 insertions(+), 32 deletions(-) diff --git a/epi_judge_cpp/CMakeLists.txt b/epi_judge_cpp/CMakeLists.txt index 5ebd80f53..b59d0095d 100644 --- a/epi_judge_cpp/CMakeLists.txt +++ b/epi_judge_cpp/CMakeLists.txt @@ -4,7 +4,7 @@ project(epi_judge_cpp) set(CMAKE_CXX_STANDARD 14) if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4018 -wd4800 -wd4805) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4018 -wd4244 -wd4800 -wd4805) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-unused-variable -Wno-sign-compare") link_libraries(pthread) diff --git a/epi_judge_cpp/drawing_skyline.cc b/epi_judge_cpp/drawing_skyline.cc index 54b3609d2..1dfa3d225 100644 --- a/epi_judge_cpp/drawing_skyline.cc +++ b/epi_judge_cpp/drawing_skyline.cc @@ -16,12 +16,14 @@ Skyline ComputeSkyline(const vector& buildings) { bool operator==(const Rectangle& a, const Rectangle& b) { return a.left == b.left && a.right == b.right && a.height == b.height; } +} // namespace drawing_skyline template <> -struct SerializationTraits - : UserSerTraits {}; +struct SerializationTraits + : UserSerTraits {}; -std::ostream& operator<<(std::ostream& out, const Rectangle& r) { +std::ostream& operator<<(std::ostream& out, + const drawing_skyline::Rectangle& r) { return PrintTo(out, std::make_tuple(r.left, r.right, r.height)); } diff --git a/epi_judge_cpp/rectangle_intersection.cc b/epi_judge_cpp/rectangle_intersection.cc index ee75363ef..5d642f31e 100644 --- a/epi_judge_cpp/rectangle_intersection.cc +++ b/epi_judge_cpp/rectangle_intersection.cc @@ -15,21 +15,25 @@ bool operator==(const Rectangle& r1, const Rectangle& r2) { std::tie(r2.x, r2.y, r2.width, r2.height); } +} // namespace rectangle_intersection + template <> -struct SerializationTraits - : UserSerTraits { +struct SerializationTraits + : UserSerTraits { static std::vector GetMetricNames(const std::string& arg_name) { return {FmtStr("area({})", arg_name), FmtStr("perimeter({})", arg_name), FmtStr("max(w, h)({})", arg_name)}; } - static std::vector GetMetrics(const Rectangle& x) { + static std::vector GetMetrics( + const rectangle_intersection::Rectangle& x) { return {x.height * x.width, 2 * (x.height + x.width), std::max(x.height, x.width)}; } }; -std::ostream& operator<<(std::ostream& out, const Rectangle& r) { +std::ostream& operator<<(std::ostream& out, + const rectangle_intersection::Rectangle& r) { return PrintTo(out, std::make_tuple(r.x, r.y, r.width, r.height)); } diff --git a/epi_judge_cpp/test_framework/binary_tree_utils.h b/epi_judge_cpp/test_framework/binary_tree_utils.h index c0c5afa8b..43d661c3f 100644 --- a/epi_judge_cpp/test_framework/binary_tree_utils.h +++ b/epi_judge_cpp/test_framework/binary_tree_utils.h @@ -29,25 +29,29 @@ void TreeGenerateHelper(const Node& tree, std::vector* result, int order) { } } +//TODO Try type extractor pattern template