[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d421eff 3/4: Remove a pointless test
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d421eff 3/4: Remove a pointless test |
Date: |
Thu, 17 Jan 2019 20:21:21 -0500 (EST) |
branch: master
commit d421effd770f670a262ae0ebc015c1d9228b11cc
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Remove a pointless test
Calling clear() on a std::stringstream without calling str() to empty it
would be dangerous, so there's no point in demonstrating that speed can
be gained in return.
---
stream_cast_test.cpp | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/stream_cast_test.cpp b/stream_cast_test.cpp
index ac75576..21473db 100644
--- a/stream_cast_test.cpp
+++ b/stream_cast_test.cpp
@@ -95,25 +95,6 @@ To cast_3(From from, To = To())
return result;
}
-/// Like cast_3<>(), but without calling str().
-
-template<typename To, typename From>
-To cast_4(From from, To = To())
-{
- static std::stringstream interpreter {imbued()};
- interpreter.clear();
- To result = To();
- if
- ( !(interpreter << from)
- || !(interpreter >> result)
- || !(interpreter >> std::ws).eof()
- )
- {
- throw std::runtime_error("Oops!");
- }
- return result;
-}
-
void assay_speed()
{
static double const e {2.718281828459045};
@@ -121,14 +102,12 @@ void assay_speed()
auto f1 = [] {for(int n = 0; n < 1000; ++n) cast_1 <std::string>(e);};
auto f2 = [] {for(int n = 0; n < 1000; ++n) cast_2 <std::string>(e);};
auto f3 = [] {for(int n = 0; n < 1000; ++n) cast_3 <std::string>(e);};
- auto f4 = [] {for(int n = 0; n < 1000; ++n) cast_4 <std::string>(e);};
std::cout
<< "\n Speed tests..."
<< "\n stream_cast : " << TimeAnAliquot(f0)
<< "\n minimalistic : " << TimeAnAliquot(f1)
<< "\n static stream : " << TimeAnAliquot(f2)
<< "\n static facet too: " << TimeAnAliquot(f3)
- << "\n without str() : " << TimeAnAliquot(f4)
<< std::endl
;
}