fixup lexical cast implementation.
gcc wouldn't compile this when "from" was of type enum, because it says it wouldn't be initialized. The explicit call to default constructor fixes it. Thanks to gfgtdf for this simple fix to this problem.
This commit is contained in:
parent
17d63fce9d
commit
0e2e54c632
1 changed files with 2 additions and 2 deletions
|
@ -88,7 +88,7 @@ struct bad_lexical_cast : public std::exception
|
|||
template<typename To, typename From>
|
||||
To lexical_cast(From a)
|
||||
{
|
||||
To res;
|
||||
To res = To();
|
||||
std::stringstream str;
|
||||
|
||||
if(str << a && str >> res) {
|
||||
|
@ -101,7 +101,7 @@ To lexical_cast(From a)
|
|||
template<typename To, typename From>
|
||||
To lexical_cast_default(From a, To def=To())
|
||||
{
|
||||
To res;
|
||||
To res = To();
|
||||
std::stringstream str;
|
||||
|
||||
if(str << a && str >> res) {
|
||||
|
|
Loading…
Add table
Reference in a new issue