diff options
| author | Martin Hořeňovský | 2017-04-25 19:54:22 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-04-25 19:54:22 +0200 |
| commit | 53864dee7b7571e6c18c1400b1792f1e4b875398 (patch) | |
| tree | 4ee94c874cccaa9cedaf6885727bfe39b4624261 /projects/SelfTest/ToStringVector.cpp | |
| parent | b245eaa7d1f0043026a1e50631db12ca6804b0e2 (diff) | |
| download | catch3-53864dee7b7571e6c18c1400b1792f1e4b875398.tar.gz | |
Fix MSVC compilation error
MSVC's `std::vector` requires its allocator to have copy constructor
from the same allocator kind, but templated over different type.
Diffstat (limited to 'projects/SelfTest/ToStringVector.cpp')
| -rw-r--r-- | projects/SelfTest/ToStringVector.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/projects/SelfTest/ToStringVector.cpp b/projects/SelfTest/ToStringVector.cpp index 002d8ef4..eafe886d 100644 --- a/projects/SelfTest/ToStringVector.cpp +++ b/projects/SelfTest/ToStringVector.cpp @@ -27,8 +27,14 @@ namespace { /* Minimal Allocator */ template<typename T> struct minimal_allocator { - typedef T value_type; - typedef std::size_t size_type; + using value_type = T; + using size_type = std::size_t; + + minimal_allocator() = default; + template <typename U> + minimal_allocator(const minimal_allocator<U>&) {} + + T *allocate( size_type n ) { return static_cast<T *>( ::operator new( n * sizeof(T) ) ); } @@ -52,8 +58,8 @@ TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator][c+ } TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator][c++11][.]" ) { - typedef std::vector<std::string,minimal_allocator<std::string> > inner; - typedef std::vector<inner> vector; + using inner = std::vector<std::string, minimal_allocator<std::string>>; + using vector = std::vector<inner>; vector v; REQUIRE( Catch::toString(v) == "{ }" ); v.push_back( inner { "hello" } ); |