File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ CXXFLAGS = -O2 -std=c++11 -I..
2
2
CXXFLAGS += -Wall -pedantic -Wextra
3
3
SPP_DEPS_1 = spp.h spp_utils.h spp_dlalloc.h spp_traits.h spp_config.h
4
4
SPP_DEPS = $(addprefix ../sparsepp/,$(SPP_DEPS_1 ) )
5
- TARGETS = emplace hash_std serialize_file serialize_stream serialize_large
5
+ TARGETS = emplace piecewise hash_std serialize_file serialize_stream serialize_large
6
6
7
7
ifeq ($(OS ) ,Windows_NT)
8
8
LDFLAGS = -lpsapi
Original file line number Diff line number Diff line change
1
+ #include < unordered_map>
2
+ #include < string>
3
+ #include < iostream>
4
+ #include < sparsepp/spp.h>
5
+
6
+ #include < sstream>
7
+
8
+ int main ()
9
+ {
10
+ using StringPtr = std::unique_ptr<std::string>;
11
+
12
+ #if 1
13
+ using StringPtrContainer = spp::sparse_hash_map<StringPtr , StringPtr >;
14
+ #else
15
+ using StringPtrContainer = std::unordered_map<StringPtr, StringPtr>;
16
+ #endif
17
+
18
+ StringPtrContainer c;
19
+
20
+ c.emplace (std::piecewise_construct,
21
+ std::forward_as_tuple (new std::string{ " key" }),
22
+ std::forward_as_tuple (new std::string{ " value" }));
23
+ }
24
+
Original file line number Diff line number Diff line change @@ -1064,6 +1064,7 @@ class sparsegroup
1064
1064
// T can be std::pair<const K, V>, but sometime we need to cast to a mutable type
1065
1065
// ------------------------------------------------------------------------------
1066
1066
typedef typename spp_::cvt<T>::type mutable_value_type;
1067
+ typedef mutable_value_type & mutable_reference;
1067
1068
typedef mutable_value_type * mutable_pointer;
1068
1069
typedef const mutable_value_type * const_mutable_pointer;
1069
1070
@@ -1332,9 +1333,9 @@ class sparsegroup
1332
1333
void _init_val (mutable_value_type *p, reference val)
1333
1334
{
1334
1335
#if !defined(SPP_NO_CXX11_RVALUE_REFERENCES)
1335
- ::new (p) value_type (std::move (val));
1336
+ ::new (p) value_type (std::move ((mutable_reference) val));
1336
1337
#else
1337
- ::new (p) value_type (val);
1338
+ ::new (p) value_type ((mutable_reference) val);
1338
1339
#endif
1339
1340
}
1340
1341
@@ -1348,7 +1349,7 @@ class sparsegroup
1348
1349
void _set_val (value_type *p, reference val)
1349
1350
{
1350
1351
#if !defined(SPP_NO_CXX11_RVALUE_REFERENCES)
1351
- *(mutable_pointer)p = std::move (val);
1352
+ *(mutable_pointer)p = std::move ((mutable_reference) val);
1352
1353
#else
1353
1354
using std::swap;
1354
1355
swap (*(mutable_pointer)p, *(mutable_pointer)&val);
You can’t perform that action at this time.
0 commit comments