From c0e1824ad6389ff29af744ff9de8626d85f2a662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 9 Feb 2018 16:39:14 +0100 Subject: [PATCH] v1.1.2 --- README.md | 2 +- docs/release-notes.md | 9 +++++++++ include/clara.hpp | 2 +- single_include/clara.hpp | 10 ++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 docs/release-notes.md diff --git a/README.md b/README.md index fe9b8b6..f7cf941 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Clara v1.1.1 +# Clara v1.1.2 [![Build Status](https://travis-ci.org/catchorg/Clara.svg?branch=master)](https://travis-ci.org/catchorg/Clara) [![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Clara?brach=master&svg=true)](https://ci.appveyor.com/project/catchorg/clara) [![codecov](https://codecov.io/gh/catchorg/Clara/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Clara) diff --git a/docs/release-notes.md b/docs/release-notes.md new file mode 100644 index 0000000..dc07b20 --- /dev/null +++ b/docs/release-notes.md @@ -0,0 +1,9 @@ + + +# 1.1.2 +* Fix usage of `dynamic_cast` preventing Clara being used with `-fno-rtti` + + +# Older versions (1.1.1 and earlier) + +No release notes have been kept (Maybe some of it will be backfilled later) diff --git a/include/clara.hpp b/include/clara.hpp index f5b2e0a..3ae9135 100644 --- a/include/clara.hpp +++ b/include/clara.hpp @@ -5,7 +5,7 @@ // // See https://github.com/philsquared/Clara for more details -// Clara v1.1.1 +// Clara v1.1.2 #ifndef CLARA_HPP_INCLUDED #define CLARA_HPP_INCLUDED diff --git a/single_include/clara.hpp b/single_include/clara.hpp index 2134a46..9a60c17 100644 --- a/single_include/clara.hpp +++ b/single_include/clara.hpp @@ -5,7 +5,7 @@ // // See https://github.com/philsquared/Clara for more details -// Clara v1.1.1 +// Clara v1.1.2 #ifndef CLARA_HPP_INCLUDED #define CLARA_HPP_INCLUDED @@ -670,12 +670,14 @@ namespace detail { struct BoundRef : NonCopyable { virtual ~BoundRef() = default; virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } }; struct BoundValueRefBase : BoundRef { virtual auto setValue( std::string const &arg ) -> ParserResult = 0; }; struct BoundFlagRefBase : BoundRef { virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } }; template @@ -907,7 +909,7 @@ namespace detail { if( token.type != TokenType::Argument ) return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); - assert( dynamic_cast( m_ref.get() ) ); + assert( !m_ref->isFlag() ); auto valueRef = static_cast( m_ref.get() ); auto result = valueRef->setValue( remainingTokens->token ); @@ -983,14 +985,14 @@ namespace detail { if( remainingTokens && remainingTokens->type == TokenType::Option ) { auto const &token = *remainingTokens; if( isMatch(token.token ) ) { - if( auto flagRef = dynamic_cast( m_ref.get() ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast( m_ref.get() ); auto result = flagRef->setFlag( true ); if( !result ) return InternalParseResult( result ); if( result.value() == ParseResultType::ShortCircuitAll ) return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); } else { - assert( dynamic_cast( m_ref.get() ) ); auto valueRef = static_cast( m_ref.get() ); ++remainingTokens; if( !remainingTokens )