Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit c0e1824

Browse files
committed
v1.1.2
1 parent fdd69fa commit c0e1824

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Clara v1.1.1
1+
# Clara v1.1.2
22
[![Build Status](https://travis-ci.org/catchorg/Clara.svg?branch=master)](https://travis-ci.org/catchorg/Clara)
33
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Clara?brach=master&svg=true)](https://ci.appveyor.com/project/catchorg/clara)
44
[![codecov](https://codecov.io/gh/catchorg/Clara/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Clara)

docs/release-notes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<a id="top"></a>
2+
3+
# 1.1.2
4+
* Fix usage of `dynamic_cast` preventing Clara being used with `-fno-rtti`
5+
6+
7+
# Older versions (1.1.1 and earlier)
8+
9+
No release notes have been kept (Maybe some of it will be backfilled later)

include/clara.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// See https://github.com/philsquared/Clara for more details
77

8-
// Clara v1.1.1
8+
// Clara v1.1.2
99

1010
#ifndef CLARA_HPP_INCLUDED
1111
#define CLARA_HPP_INCLUDED

single_include/clara.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// See https://github.com/philsquared/Clara for more details
77

8-
// Clara v1.1.1
8+
// Clara v1.1.2
99

1010
#ifndef CLARA_HPP_INCLUDED
1111
#define CLARA_HPP_INCLUDED
@@ -670,12 +670,14 @@ namespace detail {
670670
struct BoundRef : NonCopyable {
671671
virtual ~BoundRef() = default;
672672
virtual auto isContainer() const -> bool { return false; }
673+
virtual auto isFlag() const -> bool { return false; }
673674
};
674675
struct BoundValueRefBase : BoundRef {
675676
virtual auto setValue( std::string const &arg ) -> ParserResult = 0;
676677
};
677678
struct BoundFlagRefBase : BoundRef {
678679
virtual auto setFlag( bool flag ) -> ParserResult = 0;
680+
virtual auto isFlag() const -> bool { return true; }
679681
};
680682

681683
template<typename T>
@@ -907,7 +909,7 @@ namespace detail {
907909
if( token.type != TokenType::Argument )
908910
return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
909911

910-
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
912+
assert( !m_ref->isFlag() );
911913
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
912914

913915
auto result = valueRef->setValue( remainingTokens->token );
@@ -983,14 +985,14 @@ namespace detail {
983985
if( remainingTokens && remainingTokens->type == TokenType::Option ) {
984986
auto const &token = *remainingTokens;
985987
if( isMatch(token.token ) ) {
986-
if( auto flagRef = dynamic_cast<detail::BoundFlagRefBase*>( m_ref.get() ) ) {
988+
if( m_ref->isFlag() ) {
989+
auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
987990
auto result = flagRef->setFlag( true );
988991
if( !result )
989992
return InternalParseResult( result );
990993
if( result.value() == ParseResultType::ShortCircuitAll )
991994
return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
992995
} else {
993-
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
994996
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
995997
++remainingTokens;
996998
if( !remainingTokens )

0 commit comments

Comments
 (0)