Skip to content
Snippets Groups Projects
Commit d3c97cb7 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

general: retrieval of bool result from argument

parent 396b5568
No related branches found
No related tags found
1 merge request!179C casts to C++ casts redesign
...@@ -18,7 +18,7 @@ void AnyaryOperationAbstractionImpl::detachInput ( size_t index ) { ...@@ -18,7 +18,7 @@ void AnyaryOperationAbstractionImpl::detachInput ( size_t index ) {
   
bool AnyaryOperationAbstractionImpl::inputsAttached ( ) const { bool AnyaryOperationAbstractionImpl::inputsAttached ( ) const {
auto attached_lambda = [ ] ( const std::shared_ptr < abstraction::Value > & param ) { auto attached_lambda = [ ] ( const std::shared_ptr < abstraction::Value > & param ) {
return ( bool ) param; return param != nullptr;
}; };
   
return std::all_of ( m_params.begin ( ), m_params.end ( ), attached_lambda ); return std::all_of ( m_params.begin ( ), m_params.end ( ), attached_lambda );
......
...@@ -18,7 +18,7 @@ void RawAbstraction::detachInput ( size_t index ) { ...@@ -18,7 +18,7 @@ void RawAbstraction::detachInput ( size_t index ) {
   
bool RawAbstraction::inputsAttached ( ) const { bool RawAbstraction::inputsAttached ( ) const {
auto attached_lambda = [ ] ( const std::shared_ptr < abstraction::Value > & param ) { auto attached_lambda = [ ] ( const std::shared_ptr < abstraction::Value > & param ) {
return ( bool ) param; return param != nullptr;
}; };
   
return std::all_of ( m_params.begin ( ), m_params.end ( ), attached_lambda ); return std::all_of ( m_params.begin ( ), m_params.end ( ), attached_lambda );
......
...@@ -67,7 +67,7 @@ cli::CommandResult Environment::execute_line ( cli::CharSequence charSequence ) ...@@ -67,7 +67,7 @@ cli::CommandResult Environment::execute_line ( cli::CharSequence charSequence )
} }
   
Environment & Environment::getGlobalScope ( ) { Environment & Environment::getGlobalScope ( ) {
if ( ! ( bool ) m_upper ) if ( ! static_cast < bool > ( m_upper ) )
return * this; return * this;
return getGlobalScope ( ); return getGlobalScope ( );
} }
......
...@@ -16,7 +16,7 @@ class IstreamLineInterface final : public cli::LineInterface { ...@@ -16,7 +16,7 @@ class IstreamLineInterface final : public cli::LineInterface {
Stream m_is; Stream m_is;
   
bool readline ( std::string & line, bool ) override { bool readline ( std::string & line, bool ) override {
return ( bool ) std::getline ( m_is, line ); return static_cast < bool > ( std::getline ( m_is, line ) );
} }
   
public: public:
......
...@@ -292,7 +292,7 @@ public: ...@@ -292,7 +292,7 @@ public:
friend std::ostream & operator << ( std::ostream & out, const common::SparseBoolVector::element & elem ) { friend std::ostream & operator << ( std::ostream & out, const common::SparseBoolVector::element & elem ) {
out << "(" << elem.run << ", "; out << "(" << elem.run << ", ";
for ( size_t i = 0; i < sizeof ( elem.word ) * BITS_IN_BYTE; ++ i ) for ( size_t i = 0; i < sizeof ( elem.word ) * BITS_IN_BYTE; ++ i )
out << (bool) ( elem.word & 1u << i ); out << static_cast < bool > ( elem.word & 1u << i );
out << ")"; out << ")";
return out; return out;
} }
......
...@@ -10,7 +10,7 @@ static ext::vector < bool > createTestVectorBool ( size_t size ) { ...@@ -10,7 +10,7 @@ static ext::vector < bool > createTestVectorBool ( size_t size ) {
ext::vector < bool > ref; ext::vector < bool > ref;
while ( ref.size ( ) < size ) { while ( ref.size ( ) < size ) {
for ( size_t i = 0; i < sizeof ( unsigned long long ) * 8; ++i ) { for ( size_t i = 0; i < sizeof ( unsigned long long ) * 8; ++i ) {
ref.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); ref.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( size_t i = 0; i < 100; ++i ) { for ( size_t i = 0; i < 100; ++i ) {
ref.push_back ( false ); ref.push_back ( false );
...@@ -118,13 +118,13 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) { ...@@ -118,13 +118,13 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) {
common::SparseBoolVector data; common::SparseBoolVector data;
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
common::SparseBoolVector data2 = data; common::SparseBoolVector data2 = data;
...@@ -232,7 +232,7 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) { ...@@ -232,7 +232,7 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) {
   
for ( size_t i = 0; i < ref.size ( ); ++ i ) { for ( size_t i = 0; i < ref.size ( ); ++ i ) {
INFO ( "Failed on index " << i ); INFO ( "Failed on index " << i );
CHECK ( ( bool ) ref [ i ] == ( bool ) data [ i ] ); CHECK ( static_cast < bool > ( ref [ i ] ) == static_cast < bool > ( data [ i ] ) );
} }
} }
{ {
......
...@@ -393,7 +393,7 @@ public: ...@@ -393,7 +393,7 @@ public:
* \return true if the managed pointer is not null, false otherwise * \return true if the managed pointer is not null, false otherwise
*/ */
explicit operator bool( ) const { explicit operator bool( ) const {
return ( bool ) m_Data; return static_cast < bool > ( m_Data );
} }
   
}; };
......
...@@ -11,15 +11,15 @@ TEST_CASE ( "Istream", "[unit][std][bits]" ) { ...@@ -11,15 +11,15 @@ TEST_CASE ( "Istream", "[unit][std][bits]" ) {
SECTION ( "istream" ) { SECTION ( "istream" ) {
std::stringstream ss ( "TEST" ); std::stringstream ss ( "TEST" );
   
CHECK ( ( ( bool ) ( ss >> ext::string ( "TEST" ) ) ) == true ); CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TEST" ) ) ) == true );
   
ss.str ( "TEST" ); ss.str ( "TEST" );
   
CHECK ( ( ( bool ) ( ss >> ext::string ( "TESS" ) ) ) == false ); CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TESS" ) ) ) == false );
CHECK ( ss.str ( ) == "TEST" ); CHECK ( ss.str ( ) == "TEST" );
   
   
CHECK ( ( ( bool ) ( ss >> ext::string ( "TESTS" ) ) ) == false ); CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TESTS" ) ) ) == false );
CHECK ( ss.str ( ) == "TEST" ); CHECK ( ss.str ( ) == "TEST" );
} }
} }
...@@ -151,7 +151,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -151,7 +151,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
} }
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
data >>= sizeof ( unsigned long long ) * 6 + shift; data >>= sizeof ( unsigned long long ) * 6 + shift;
...@@ -162,7 +162,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -162,7 +162,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
} }
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
ref.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); ref.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
ref.resize ( 192 + offset ); ref.resize ( 192 + offset );
...@@ -179,7 +179,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -179,7 +179,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
ext::vector < bool > data; ext::vector < bool > data;
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
shadow >>= 10; shadow >>= 10;
...@@ -187,7 +187,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -187,7 +187,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
   
ext::vector < bool > ref; ext::vector < bool > ref;
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
ref.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); ref.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
CAPTURE ( data ,ref ); CAPTURE ( data ,ref );
...@@ -204,13 +204,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -204,13 +204,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
ext::vector < bool > data; ext::vector < bool > data;
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
ext::vector < bool > data2 = data; ext::vector < bool > data2 = data;
...@@ -257,7 +257,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -257,7 +257,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
} }
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
data <<= sizeof ( unsigned long long ) * 2 + shift; data <<= sizeof ( unsigned long long ) * 2 + shift;
...@@ -272,7 +272,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -272,7 +272,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
} }
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
ref.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); ref.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
ref.resize ( 128 + offset ); ref.resize ( 128 + offset );
...@@ -289,7 +289,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -289,7 +289,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
ext::vector < bool > data; ext::vector < bool > data;
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
shadow <<= 10; shadow <<= 10;
...@@ -297,7 +297,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -297,7 +297,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
   
ext::vector < bool > ref; ext::vector < bool > ref;
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
ref.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); ref.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
std::cout << "data = " << data << std::endl; std::cout << "data = " << data << std::endl;
...@@ -315,13 +315,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ...@@ -315,13 +315,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) {
ext::vector < bool > data; ext::vector < bool > data;
   
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) {
data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) );
} }
   
ext::vector < bool > data2 = data; ext::vector < bool > data2 = data;
......
...@@ -27,7 +27,7 @@ void BasicLexer::consume ( std::istream & input, const std::string & value ) { ...@@ -27,7 +27,7 @@ void BasicLexer::consume ( std::istream & input, const std::string & value ) {
} }
   
bool BasicLexer::testAndConsume ( std::istream & input, const std::string & value ) { bool BasicLexer::testAndConsume ( std::istream & input, const std::string & value ) {
return ( bool ) ( input >> ext::string ( value ) ); return static_cast < bool > ( input >> ext::string ( value ) );
} }
   
} /* namespace ext */ } /* namespace ext */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment