diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 15:09:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 15:09:17 +0200 |
commit | f8bb2faef4b272ed150eb3ca4cedaa79da410694 (patch) | |
tree | fff08a4d3ce6380709c84dc6b93d02de097dd7d5 /libxsde/xsde/cxx/hybrid/sequence.txx | |
parent | da1ce0f39a36a2fca1f8d51a67b92be6368ddbfd (diff) |
Allow initialization of pod_seq and fix_seq from a C array
Use this in the hybrid/binary/custom example.
Diffstat (limited to 'libxsde/xsde/cxx/hybrid/sequence.txx')
-rw-r--r-- | libxsde/xsde/cxx/hybrid/sequence.txx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/hybrid/sequence.txx b/libxsde/xsde/cxx/hybrid/sequence.txx index 12faa99..a81ad11 100644 --- a/libxsde/xsde/cxx/hybrid/sequence.txx +++ b/libxsde/xsde/cxx/hybrid/sequence.txx @@ -28,6 +28,34 @@ namespace xsde #ifdef XSDE_EXCEPTIONS template <typename T> void fix_seq<T>:: + assign (const T* p, size_t n) + { + clear (); + reserve (n); + + for (; size_ < n; ++size_) + new (static_cast<T*> (data_) + size_) T (p[size_]); + } +#else + template <typename T> + sequence_base::error fix_seq<T>:: + assign (const T* p, size_t n) + { + clear (); + + if (error r = reserve (n)) + return r; + + for (; size_ < n; ++size_) + new (static_cast<T*> (data_) + size_) T (p[size_]); + + return error_none; + } +#endif + +#ifdef XSDE_EXCEPTIONS + template <typename T> + void fix_seq<T>:: move_ (void* dst, void* src, size_t n) { T* d = static_cast<T*> (dst); |