diff --git a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.cpp b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.cpp index 6af1eb8fefe04a8a935a0e1668ea510a4977bfbd..669215378b0cd79171b7999a4ec395507ed9ada7 100644 --- a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.cpp +++ b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.cpp @@ -18,7 +18,7 @@ void AnyaryOperationAbstractionImpl::detachInput ( size_t index ) { bool AnyaryOperationAbstractionImpl::inputsAttached ( ) const { 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 ); diff --git a/alib2abstraction/src/abstraction/RawAbstraction.cpp b/alib2abstraction/src/abstraction/RawAbstraction.cpp index d05cfe4c571d31430f092c9b6fc786cc26f1b5bf..182da82cb9feb31da7aa055049ef0b9d4cf4db59 100644 --- a/alib2abstraction/src/abstraction/RawAbstraction.cpp +++ b/alib2abstraction/src/abstraction/RawAbstraction.cpp @@ -18,7 +18,7 @@ void RawAbstraction::detachInput ( size_t index ) { bool RawAbstraction::inputsAttached ( ) const { 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 ); diff --git a/alib2cli/src/environment/Environment.cpp b/alib2cli/src/environment/Environment.cpp index 920dede7403e91554d2e55ed15fc736977daf899..431776336973db9880ea7c4f70f9fbd0baecef6f 100644 --- a/alib2cli/src/environment/Environment.cpp +++ b/alib2cli/src/environment/Environment.cpp @@ -67,7 +67,7 @@ cli::CommandResult Environment::execute_line ( cli::CharSequence charSequence ) } Environment & Environment::getGlobalScope ( ) { - if ( ! ( bool ) m_upper ) + if ( ! static_cast < bool > ( m_upper ) ) return * this; return getGlobalScope ( ); } diff --git a/alib2cli/src/readline/IstreamLineInterface.h b/alib2cli/src/readline/IstreamLineInterface.h index 9eb1527677c38e1e8170dec14dd73b17ddb570b8..d2c9a316981d2af7c729b6ab8859a3643525af54 100644 --- a/alib2cli/src/readline/IstreamLineInterface.h +++ b/alib2cli/src/readline/IstreamLineInterface.h @@ -16,7 +16,7 @@ class IstreamLineInterface final : public cli::LineInterface { Stream m_is; bool readline ( std::string & line, bool ) override { - return ( bool ) std::getline ( m_is, line ); + return static_cast < bool > ( std::getline ( m_is, line ) ); } public: diff --git a/alib2data/src/common/SparseBoolVector.hpp b/alib2data/src/common/SparseBoolVector.hpp index c0c864f21daf89b41ef82c0e567ee6d9f81d7a52..dabdd912a6f69708858d9305276d5b39b3f5458f 100644 --- a/alib2data/src/common/SparseBoolVector.hpp +++ b/alib2data/src/common/SparseBoolVector.hpp @@ -292,7 +292,7 @@ public: friend std::ostream & operator << ( std::ostream & out, const common::SparseBoolVector::element & elem ) { out << "(" << elem.run << ", "; 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 << ")"; return out; } diff --git a/alib2data/test-src/common/SparseBoolVectorTest.cpp b/alib2data/test-src/common/SparseBoolVectorTest.cpp index 993a5238c7a9baa480dbad75ddf0d05c26dcc3b0..5ae7afb076665f291624c06a3b6a34496282ff3c 100644 --- a/alib2data/test-src/common/SparseBoolVectorTest.cpp +++ b/alib2data/test-src/common/SparseBoolVectorTest.cpp @@ -10,7 +10,7 @@ static ext::vector < bool > createTestVectorBool ( size_t size ) { ext::vector < bool > ref; while ( ref.size ( ) < size ) { 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 ) { ref.push_back ( false ); @@ -118,13 +118,13 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) { common::SparseBoolVector data; 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 ) { - 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 ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) ); } common::SparseBoolVector data2 = data; @@ -232,7 +232,7 @@ TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) { for ( size_t i = 0; i < ref.size ( ); ++ i ) { INFO ( "Failed on index " << i ); - CHECK ( ( bool ) ref [ i ] == ( bool ) data [ i ] ); + CHECK ( static_cast < bool > ( ref [ i ] ) == static_cast < bool > ( data [ i ] ) ); } } { diff --git a/alib2std/src/extensions/memory.hpp b/alib2std/src/extensions/memory.hpp index 19bb3ec61257af759b7243692b184558a1780fd8..edd6c2a594a736240df17e5788ac6f3103bc74f8 100644 --- a/alib2std/src/extensions/memory.hpp +++ b/alib2std/src/extensions/memory.hpp @@ -393,7 +393,7 @@ public: * \return true if the managed pointer is not null, false otherwise */ explicit operator bool( ) const { - return ( bool ) m_Data; + return static_cast < bool > ( m_Data ); } }; diff --git a/alib2std/test-src/extensions/IstreamTest.cpp b/alib2std/test-src/extensions/IstreamTest.cpp index d53e182df7c8ac7f698bba0d7b7f55510b9797f7..37b30d2226520f8466ed5b991c3d5a7fcaa60afc 100644 --- a/alib2std/test-src/extensions/IstreamTest.cpp +++ b/alib2std/test-src/extensions/IstreamTest.cpp @@ -11,15 +11,15 @@ TEST_CASE ( "Istream", "[unit][std][bits]" ) { SECTION ( "istream" ) { std::stringstream ss ( "TEST" ); - CHECK ( ( ( bool ) ( ss >> ext::string ( "TEST" ) ) ) == true ); + CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TEST" ) ) ) == true ); ss.str ( "TEST" ); - CHECK ( ( ( bool ) ( ss >> ext::string ( "TESS" ) ) ) == false ); + CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TESS" ) ) ) == false ); CHECK ( ss.str ( ) == "TEST" ); - CHECK ( ( ( bool ) ( ss >> ext::string ( "TESTS" ) ) ) == false ); + CHECK ( ( static_cast < bool > ( ss >> ext::string ( "TESTS" ) ) ) == false ); CHECK ( ss.str ( ) == "TEST" ); } } diff --git a/alib2std/test-src/extensions/container/VectorTest.cpp b/alib2std/test-src/extensions/container/VectorTest.cpp index 4155ca2b746b26b6e422d1b16ad5b8d45a1076cf..d63013fafa6d60fb20991037530ac53789579f9d 100644 --- a/alib2std/test-src/extensions/container/VectorTest.cpp +++ b/alib2std/test-src/extensions/container/VectorTest.cpp @@ -151,7 +151,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { } 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; @@ -162,7 +162,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { } 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 ); @@ -179,7 +179,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > data; 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; @@ -187,7 +187,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > ref; 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 ); @@ -204,13 +204,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > data; 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 ) { - 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 ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) ); } ext::vector < bool > data2 = data; @@ -257,7 +257,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { } 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; @@ -272,7 +272,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { } 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 ); @@ -289,7 +289,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > data; 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; @@ -297,7 +297,7 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > ref; 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; @@ -315,13 +315,13 @@ TEST_CASE ( "Vector", "[unit][std][container]" ) { ext::vector < bool > data; 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 ) { - 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 ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + data.push_back ( static_cast < bool > ( shadow & ( 1ULL << i ) ) ); } ext::vector < bool > data2 = data; diff --git a/alib2str/src/common/lexer.cpp b/alib2str/src/common/lexer.cpp index 6d9861178c64a8d2577e7152f9c496033d954ab2..19a9ae9addfbdd82d94add6c1865f57edb502ad9 100644 --- a/alib2str/src/common/lexer.cpp +++ b/alib2str/src/common/lexer.cpp @@ -27,7 +27,7 @@ void BasicLexer::consume ( 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 */