Skip to content

Commit

Permalink
Merge pull request ToruNiina#176 from GMLC-TDC/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
ToruNiina authored Nov 24, 2021
2 parents bcee9f2 + 9c1708c commit 1dc09d0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ option(toml11_TEST_WITH_UBSAN "use LLVM undefined behavior sanitizer" OFF)

include(CheckCXXCompilerFlag)
if("${CMAKE_VERSION}" VERSION_GREATER 3.1)
set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard whose features are requested to build all targets.")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Boolean describing whether the value of CXX_STANDARD is a requirement.")
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Boolean specifying whether compiler specific extensions are requested.")
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard whose features are requested to build all targets.")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Boolean describing whether the value of CXX_STANDARD is a requirement.")
else()
# Manually check for C++11 compiler flag.
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
Expand Down
5 changes: 5 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4820")
# pragma warning(pop): likely mismatch, popping warning state pushed in different file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5031")
# pragma warning(pop): spectre warnings in tests
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5045")
# pragma warning(pop): spectre warnings in tests
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4265")
endif()

find_package(Boost COMPONENTS unit_test_framework REQUIRED)
Expand Down Expand Up @@ -185,6 +189,7 @@ option(TOML11_REQUIRE_FILESYSTEM_LIBRARY "need to link -lstdc++fs or -lc++fs" OF
foreach(TEST_NAME ${TEST_NAMES})
add_executable(${TEST_NAME} ${TEST_NAME}.cpp)
target_link_libraries(${TEST_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} toml11::toml11)
target_include_directories(${TEST_NAME} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})

# to compile tests with <filesystem>...
if(TOML11_REQUIRE_FILESYSTEM_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion toml/get.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ get(basic_value<C, M, V>&& v)
// ============================================================================
// std::string_view

#if __cplusplus >= 201703L
#if defined(TOML11_USING_STRING_VIEW) && TOML11_USING_STRING_VIEW>0
template<typename T, typename C,
template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, std::string_view>::value, std::string_view>
Expand Down
3 changes: 2 additions & 1 deletion toml/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#if __cplusplus >= 201703L
#if __has_include(<string_view>)
#define TOML11_USING_STRING_VIEW 1
#include <string_view>
#endif
#endif
Expand Down Expand Up @@ -53,7 +54,7 @@ struct string
string& operator+=(const std::string& rhs) {str += rhs; return *this;}
string& operator+=(const string& rhs) {str += rhs.str; return *this;}

#if __cplusplus >= 201703L
#if defined(TOML11_USING_STRING_VIEW) && TOML11_USING_STRING_VIEW>0
explicit string(std::string_view s): kind(string_t::basic), str(s){}
string(std::string_view s, string_t k): kind(k), str(s){}

Expand Down
4 changes: 3 additions & 1 deletion toml/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ struct is_container : conjunction<
negation<is_map<T>>, // not a map
negation<std::is_same<T, std::string>>, // not a std::string
#if __cplusplus >= 201703L
#if __has_include(<string_view>)
negation<std::is_same<T, std::string_view>>, // not a std::string_view
#endif // has_include(<string_view>)
#endif
has_iterator<T>, // has T::iterator
has_value_type<T> // has T::value_type
Expand Down Expand Up @@ -280,7 +282,7 @@ using enable_if_t = typename std::enable_if<B, T>::type;
// ---------------------------------------------------------------------------
// return_type_of_t

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable>=201703

template<typename F, typename ... Args>
using return_type_of_t = std::invoke_result_t<F, Args...>;
Expand Down
2 changes: 1 addition & 1 deletion toml/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class basic_value
assigner(this->string_, toml::string(std::string(s), kind));
}

#if __cplusplus >= 201703L
#if defined(TOML11_USING_STRING_VIEW) && TOML11_USING_STRING_VIEW>0
basic_value(std::string_view s)
: type_(value_t::string),
region_info_(std::make_shared<region_base>(region_base{}))
Expand Down

0 comments on commit 1dc09d0

Please sign in to comment.