mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
Add allocator support to StringMaker<vector>
- also extracted out 'rangeToString', in an attempt to make it easier to add support for other containers
This commit is contained in:
parent
1e2f1d1603
commit
0dbcf218c3
@ -99,19 +99,27 @@ struct StringMaker<T*> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
namespace Detail {
|
||||||
struct StringMaker<std::vector<T> > {
|
template<typename InputIterator>
|
||||||
static std::string convert( std::vector<T> const& v ) {
|
std::string rangeToString( InputIterator first, InputIterator last ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "{ ";
|
oss << "{ ";
|
||||||
for( std::size_t i = 0; i < v.size(); ++ i ) {
|
if( first != last ) {
|
||||||
oss << toString( v[i] );
|
oss << toString( *first );
|
||||||
if( i < v.size() - 1 )
|
for( ++first ; first != last ; ++first ) {
|
||||||
oss << ", ";
|
oss << ", " << toString( *first );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oss << " }";
|
oss << " }";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename Allocator>
|
||||||
|
struct StringMaker<std::vector<T, Allocator> > {
|
||||||
|
static std::string convert( std::vector<T,Allocator> const& v ) {
|
||||||
|
return Detail::rangeToString( v.begin(), v.end() );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v1.0 build 10 (master branch)
|
* CATCH v1.0 build 10 (master branch)
|
||||||
* Generated: 2013-09-14 19:56:34.776409
|
* Generated: 2013-09-17 22:21:47.780755
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -722,19 +722,27 @@ struct StringMaker<T*> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
namespace Detail {
|
||||||
struct StringMaker<std::vector<T> > {
|
template<typename InputIterator>
|
||||||
static std::string convert( std::vector<T> const& v ) {
|
std::string rangeToString( InputIterator first, InputIterator last ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "{ ";
|
oss << "{ ";
|
||||||
for( std::size_t i = 0; i < v.size(); ++ i ) {
|
if( first != last ) {
|
||||||
oss << toString( v[i] );
|
oss << toString( *first );
|
||||||
if( i < v.size() - 1 )
|
for( ++first ; first != last ; ++first ) {
|
||||||
oss << ", ";
|
oss << ", " << toString( *first );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oss << " }";
|
oss << " }";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename Allocator>
|
||||||
|
struct StringMaker<std::vector<T, Allocator> > {
|
||||||
|
static std::string convert( std::vector<T,Allocator> const& v ) {
|
||||||
|
return Detail::rangeToString( v.begin(), v.end() );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
Loading…
Reference in New Issue
Block a user