Skip to content

Commit

Permalink
Merge pull request #2540 from karzhenkov/disrupt-cxx17-tests
Browse files Browse the repository at this point in the history
Travis doesn't run any tests in C++17 mode
  • Loading branch information
nlohmann authored Dec 21, 2020
2 parents c3c574c + 9493f4b commit f78d456
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ matrix:
compiler: gcc
env:
- COMPILER=g++-9
- CXXFLAGS=-std=c++2a
- CXX_STANDARD=17
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
Expand Down Expand Up @@ -294,11 +294,11 @@ matrix:
compiler: clang
env:
- COMPILER=clang++-7
- CXXFLAGS=-std=c++1z
- CXX_STANDARD=17
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
packages: ['g++-6', 'clang-7', 'ninja-build']
packages: ['g++-7', 'clang-7', 'ninja-build']

################
# build script #
Expand All @@ -321,6 +321,9 @@ script:
# by default, use implicit conversions
- if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi

# append CXX_STANDARD to CMAKE_OPTIONS if required
- CMAKE_OPTIONS+=${CXX_STANDARD:+ -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CXX_STANDARD_REQUIRED=ON}

# compile and execute unit tests
- mkdir -p build && cd build
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
Expand Down
4 changes: 4 additions & 0 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ SOFTWARE.
#include <nlohmann/json_fwd.hpp>
#include <nlohmann/ordered_map.hpp>

#if defined(JSON_HAS_CPP_17)
#include <string_view>
#endif

/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
Expand Down
4 changes: 4 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16663,6 +16663,10 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
} // namespace nlohmann


#if defined(JSON_HAS_CPP_17)
#include <string_view>
#endif

/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
Expand Down
4 changes: 0 additions & 4 deletions test/src/unit-conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ using nlohmann::json;
#define JSON_HAS_CPP_14
#endif

#if defined(JSON_HAS_CPP_17)
#include <string_view>
#endif

TEST_CASE("value conversion")
{
SECTION("get an object (explicit)")
Expand Down

0 comments on commit f78d456

Please sign in to comment.