Thank you Jochen, Yes, I see PersistentValueMap and PersistentValueVector class templates there.
Unfortunately, they have a couple of minor issues: 1. PersistentValueVector has no public function to get a v8::Isolate instance used for values in the vector. 2. It's not possible to enumerate all items stored in a PersistentValueMap, since its interface has no any kind of iterators. Thus, I decided to use standard containers :) Move-only persistents work fine in standard containers even with pretty old compilers: Visual C++2010 and GCC 4.6.3 On Monday, July 14, 2014 7:09:16 PM UTC+4, Jochen Eisinger wrote: > > Not all platforms we're targeting support C++11 yet :( > > As a work around, we provide map and vector implementations in v8-util.h > that can be used with persistent values. > > best > -jochen > > > On Mon, Jul 14, 2014 at 4:24 PM, Pavel Medvedev <[email protected] > <javascript:>> wrote: > >> Hello, >> >> Is anybody storing UniquePersistent values in standard associative >> containers? When I tried to store UniquePersistent values in a >> std::unordered_map, I got an error with GCC: >> >> #include <unordered_map> >> #include <v8.h> >> >> void add(v8::Isolate* isolate, int key, v8::Handle<v8::Value> value) >> { >> std::unordered_map<int, v8::UniquePersistent<v8::Value>> map; >> >> v8::UniquePersistent<v8::Value> pvalue(isolate, value); >> map.insert(std::make_pair(key, std::move(pvalue))); >> } >> >> When I add move constructor and assignment, it works: >> >> // Moveable unique persistent >> template<typename T> >> struct MoveablePersistent : public v8::UniquePersistent<T> >> { >> typedef v8::UniquePersistent<T> base_class; >> >> MoveablePersistent() >> : base_class() >> { >> } >> >> template<typename S> >> MoveablePersistent(v8::Isolate* isolate, v8::Handle<S> const& handle) >> : base_class(isolate, handle) >> { >> } >> >> template<typename S> >> MoveablePersistent(v8::Isolate* isolate, v8::PersistentBase<S> const& >> handle) >> : base_class(isolate, handle) >> { >> } >> >> MoveablePersistent(MoveablePersistent&& src) >> : base_class(src.Pass()) >> { >> } >> >> MoveablePersistent& operator=(MoveablePersistent&& src) >> { >> if (&src != this) >> { >> base_class::operator=(src.Pass()); >> } >> return *this; >> } >> }; >> >> >> void add(v8::Isolate* isolate, int key, v8::Handle<v8::Value> value) >> { >> std::unordered_map<int, MoveablePersistent<v8::Value>> map; >> >> MoveablePersistent<v8::Value> pvalue(isolate, value); >> map.insert(std::make_pair(key, std::move(pvalue))); >> } >> >> >> Is it possible to add move semanics support for UniquePresistent values >> in C++11 mode? >> >> Cheers, Pavel >> >> -- >> -- >> v8-users mailing list >> [email protected] <javascript:> >> http://groups.google.com/group/v8-users >> --- >> You received this message because you are subscribed to the Google Groups >> "v8-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
