mirror of
https://github.com/boostorg/lambda2.git
synced 2025-05-11 13:44:05 +00:00
Update tests with std::ref(is), std::ref(os)
This commit is contained in:
parent
f2ab3ade7c
commit
d6389b60f5
@ -7,7 +7,20 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
template<class T> T from_string( std::string const& s )
|
||||
template<class T> T from_string_1( std::string const& s )
|
||||
{
|
||||
using namespace boost::lambda2;
|
||||
|
||||
std::istringstream is( s );
|
||||
|
||||
T t{};
|
||||
|
||||
( std::ref( is ) >> _1 )( t );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
template<class T> T from_string_2( std::string const& s )
|
||||
{
|
||||
using namespace boost::lambda2;
|
||||
|
||||
@ -22,7 +35,8 @@ template<class T> T from_string( std::string const& s )
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( from_string<int>( "123" ), 123 );
|
||||
BOOST_TEST_EQ( from_string_1<int>( "123" ), 123 );
|
||||
BOOST_TEST_EQ( from_string_2<int>( "456" ), 456 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -7,7 +7,18 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
template<class T> std::string to_string( T const& t )
|
||||
template<class T> std::string to_string_1( T const& t )
|
||||
{
|
||||
using namespace boost::lambda2;
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
( std::ref( os ) << _1 )( t );
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template<class T> std::string to_string_2( T const& t )
|
||||
{
|
||||
using namespace boost::lambda2;
|
||||
|
||||
@ -20,7 +31,8 @@ template<class T> std::string to_string( T const& t )
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( to_string( 123 ), "123" );
|
||||
BOOST_TEST_EQ( to_string_1( 123 ), "123" );
|
||||
BOOST_TEST_EQ( to_string_2( 456 ), "456" );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user