Skip to content

Commit

Permalink
Fix #296. Fix #301.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Feb 3, 2022
1 parent 1643777 commit c34f2a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
8 changes: 7 additions & 1 deletion doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.2.3

Released: 2022-02-03

* Fixed `static_assert` in `demangle()` with recent MSVC.

## 3.2.2

Released 2021-10-22
Expand Down Expand Up @@ -638,4 +644,4 @@ Released 2008
Development of the PEGTL started in November 2007 as an experiment in C++0x.
It is based on ideas from the YARD library by Christopher Diggins.
Copyright (c) 2007-2021 Dr. Colin Hirsch and Daniel Frey
Copyright (c) 2007-2022 Dr. Colin Hirsch and Daniel Frey
16 changes: 9 additions & 7 deletions include/tao/pegtl/demangle.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL

#ifndef TAO_PEGTL_DEMANGLE_HPP
Expand All @@ -9,6 +9,8 @@

#include "config.hpp"

#include "internal/dependent_true.hpp"

namespace TAO_PEGTL_NAMESPACE
{
#if defined( __clang__ )
Expand All @@ -20,7 +22,7 @@ namespace TAO_PEGTL_NAMESPACE
{
constexpr std::string_view sv = __PRETTY_FUNCTION__;
constexpr auto begin = sv.find( '=' );
static_assert( begin != std::string_view::npos );
static_assert( internal::dependent_true< T > && ( begin != std::string_view::npos ) );
return sv.substr( begin + 2, sv.size() - begin - 3 );
}

Expand All @@ -45,7 +47,7 @@ namespace TAO_PEGTL_NAMESPACE
{
constexpr std::string_view sv = __PRETTY_FUNCTION__;
constexpr auto begin = find< '=' >( sv.data(), sv.size() );
static_assert( begin != nullptr );
static_assert( internal::dependent_true< T > && ( begin != nullptr ) );
return { begin + 2, sv.data() + sv.size() - begin - 3 };
}

Expand Down Expand Up @@ -85,10 +87,10 @@ namespace TAO_PEGTL_NAMESPACE
{
constexpr std::string_view sv = __PRETTY_FUNCTION__;
constexpr auto begin = sv.find( '=' );
static_assert( begin != std::string_view::npos );
static_assert( internal::dependent_true< T > && ( begin != std::string_view::npos ) );
constexpr auto tmp = sv.substr( begin + 2 );
constexpr auto end = tmp.rfind( ';' );
static_assert( end != std::string_view::npos );
static_assert( internal::dependen_true< T > && ( end != std::string_view::npos ) );
return tmp.substr( 0, end );
}

Expand All @@ -115,10 +117,10 @@ namespace TAO_PEGTL_NAMESPACE
{
constexpr std::string_view sv = __FUNCSIG__;
constexpr auto begin = sv.find( "demangle<" );
static_assert( begin != std::string_view::npos );
static_assert( internal::dependen_true< T > && ( begin != std::string_view::npos ) );
constexpr auto tmp = sv.substr( begin + 9 );
constexpr auto end = tmp.rfind( '>' );
static_assert( end != std::string_view::npos );
static_assert( internal::dependent_true< T > && ( end != std::string_view::npos ) );
return tmp.substr( 0, end );
}

Expand Down
16 changes: 16 additions & 0 deletions include/tao/pegtl/internal/dependent_true.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef TAO_PEGTL_INTERNAL_DEPENDENT_TRUE_HPP
#define TAO_PEGTL_INTERNAL_DEPENDENT_TRUE_HPP

#include "../config.hpp"

namespace TAO_PEGTL_NAMESPACE::internal
{
template< typename... >
inline constexpr bool dependent_true = true;

} // namespace TAO_PEGTL_NAMESPACE::internal

#endif

0 comments on commit c34f2a2

Please sign in to comment.