Skip to content

Commit

Permalink
Fix no-exceptions build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Dec 14, 2024
1 parent 63a8fd1 commit e7a55fe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/example/pegtl/coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

#if defined( __cpp_exception )

#include <cassert>
#include <charconv>
#include <cstdlib>
#include <filesystem>
#include <iomanip>
Expand All @@ -14,7 +17,6 @@
#include <vector>

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/integer.hpp>

namespace coverage
{
Expand Down Expand Up @@ -140,9 +142,9 @@ namespace coverage
{
assert( !in.empty() );
std::size_t t = 0;
const bool b = pegtl::internal::convert_unsigned( t, in.string_view() );
(void)b;
assert( b );
const auto p = std::from_chars( in.begin(), in.end(), t );
(void)p;
assert( p.ptr == in.end() );
assert( t > 0 );
st.number = t - 1;
st.count = std::nullopt;
Expand Down Expand Up @@ -319,3 +321,12 @@ int main( int argc, char** argv )
coverage::coverage( std::vector< std::string >( argv + 1, argv + argc ) ).report();
return 0;
}

#else

int main( int /*unused*/, char** /*unused*/ )
{
return 0;
}

#endif
16 changes: 15 additions & 1 deletion src/test/pegtl/contrib_integer_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

#include "test.hpp"

#if defined( __cpp_exceptions )

#include <tao/pegtl/contrib/integer.hpp>

namespace TAO_PEGTL_NAMESPACE
{

void unit_test()
{
for( char c = 2; c < 122; ++c ) {
Expand Down Expand Up @@ -156,4 +157,17 @@ namespace TAO_PEGTL_NAMESPACE

} // namespace TAO_PEGTL_NAMESPACE

#else

namespace TAO_PEGTL_NAMESPACE
{
void unit_test()
{
std::cerr << "Skipping convert test..." << std::endl;
}

} // namespace TAO_PEGTL_NAMESPACE

#endif

#include "main.hpp"
2 changes: 1 addition & 1 deletion src/test/pegtl/internal_mmap_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "test.hpp"

#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 )
#if defined( __cpp_exceptions ) && ( defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) )

#include "verify_file.hpp"

Expand Down

0 comments on commit e7a55fe

Please sign in to comment.