From 0563fecfbf442460d607d159e6ddba2b7c9231e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com>
Date: Sun, 30 Sep 2018 22:02:47 +0200
Subject: [PATCH] Fixed templated String constructor and added constructor from
 bool.

---
 src/TNL/String.cpp                    | 7 +++++++
 src/TNL/String.h                      | 4 +++-
 src/UnitTests/Containers/ListTest.cpp | 5 +++--
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/TNL/String.cpp b/src/TNL/String.cpp
index 40e36bbde0..292d90c0a5 100644
--- a/src/TNL/String.cpp
+++ b/src/TNL/String.cpp
@@ -47,6 +47,13 @@ String::String( const String& str )
    setString( str.getString() );
 }
 
+String::String( const bool b )
+   : string( nullptr ), length( 0 )
+{
+   if( b ) this->setString( "true" );
+   else this->setString( "false" );
+}
+
 String String::getType()
 {
    return String( "String" );
diff --git a/src/TNL/String.h b/src/TNL/String.h
index 96f625b006..f5657a20ff 100644
--- a/src/TNL/String.h
+++ b/src/TNL/String.h
@@ -59,7 +59,7 @@ public:
    /// definition ( in operator << ). It leads to stack overflow and segmentation fault.
    template< typename T >
    explicit
-   String( T value )
+   String( const T& value )
       : string( nullptr ), length( 0 )
    {
       std::stringstream str;
@@ -67,6 +67,8 @@ public:
       setString( str.str().data() );
    }
 
+   String( const bool b );
+
    //! Destructor
    ~String();
    
diff --git a/src/UnitTests/Containers/ListTest.cpp b/src/UnitTests/Containers/ListTest.cpp
index 8ff4713f88..3b5fdaecf3 100644
--- a/src/UnitTests/Containers/ListTest.cpp
+++ b/src/UnitTests/Containers/ListTest.cpp
@@ -41,16 +41,17 @@ TYPED_TEST_CASE( ListTest, ListTypes );
 TYPED_TEST( ListTest, constructor )
 {
    using ListType = typename TestFixture::ListType;
+   using ValueType = typename ListType::ValueType;
 
    ListType list;
    EXPECT_TRUE( list.isEmpty() );
    EXPECT_EQ( list.getSize(), 0 );
 
-   list.Append( 0 );
+   list.Append( ( ValueType ) 0 );
    EXPECT_EQ( list.getSize(), 1 );
 
    ListType copy( list );
-   list.Append( 0 );
+   list.Append( ( ValueType ) 0 );
    EXPECT_EQ( list.getSize(), 2 );
    EXPECT_EQ( copy.getSize(), 1 );
    EXPECT_EQ( copy[ 0 ], list[ 0 ] );
-- 
GitLab