|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82323 - in sandbox/static_vector: boost/container boost/container/detail test
From: adam.wulkiewicz_at_[hidden]
Date: 2013-01-02 15:01:55
Author: awulkiew
Date: 2013-01-02 15:01:54 EST (Wed, 02 Jan 2013)
New Revision: 82323
URL: http://svn.boost.org/trac/boost/changeset/82323
Log:
Boost.Interprocess pointers used instead of raw pointers in static_vector_interprocess test.
Some comments added.
Text files modified:
sandbox/static_vector/boost/container/detail/static_vector_util.hpp | 2 +-
sandbox/static_vector/boost/container/static_vector.hpp | 5 +++--
sandbox/static_vector/test/static_vector_interprocess_test.cpp | 25 ++++++++++++++++++++++---
sandbox/static_vector/test/static_vector_test.cpp | 20 ++++++++++----------
4 files changed, 36 insertions(+), 16 deletions(-)
Modified: sandbox/static_vector/boost/container/detail/static_vector_util.hpp
==============================================================================
--- sandbox/static_vector/boost/container/detail/static_vector_util.hpp (original)
+++ sandbox/static_vector/boost/container/detail/static_vector_util.hpp 2013-01-02 15:01:54 EST (Wed, 02 Jan 2013)
@@ -734,7 +734,7 @@
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-// uninitialized_copy_checked
+// uninitialized_copy_s
template <typename I, typename F>
inline std::size_t uninitialized_copy_s(I first, I last, F dest, std::size_t max_count)
Modified: sandbox/static_vector/boost/container/static_vector.hpp
==============================================================================
--- sandbox/static_vector/boost/container/static_vector.hpp (original)
+++ sandbox/static_vector/boost/container/static_vector.hpp 2013-01-02 15:01:54 EST (Wed, 02 Jan 2013)
@@ -1167,7 +1167,7 @@
aligned_storage_type m_storage;
};
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template<typename Value, typename Strategy>
class static_vector<Value, 0, Strategy>
@@ -1412,6 +1412,7 @@
size_type max_size() const { return 0; }
size_type size() const { return 0; }
bool empty() const { return true; }
+ void shrink_to_fit() {}
private:
@@ -1426,7 +1427,7 @@
}
};
-#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#endif // !BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION && !BOOST_CONTAINER_DOXYGEN_INVOKED
// comparisons
template<typename V, std::size_t C, typename S>
Modified: sandbox/static_vector/test/static_vector_interprocess_test.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector_interprocess_test.cpp (original)
+++ sandbox/static_vector/test/static_vector_interprocess_test.cpp 2013-01-02 15:01:54 EST (Wed, 02 Jan 2013)
@@ -19,8 +19,19 @@
#include "static_vector_test.hpp"
#include <boost/interprocess/managed_shared_memory.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
#include <algorithm>
+template <typename V, typename SegmentManager>
+struct interprocess_strategy /*interprocess_null_allocator*/
+ : public boost::interprocess::allocator<V, SegmentManager>
+{
+ static void allocate_failed()
+ {
+ boost::container::static_vector_detail::default_strategy<V>::allocate_failed();
+ }
+};
+
template <typename T, size_t N>
void test_interprocess(T const& t)
{
@@ -33,17 +44,25 @@
bi::managed_shared_memory shmem(bi::create_only, "shared_memory", 10000 + sizeof(T) * N);
- typedef static_vector<T, N> SV;
- SV * sv_ptr = shmem.construct<SV>("my_object")(N, t);
+ typedef static_vector<
+ T, N,
+ interprocess_strategy<T, bi::managed_shared_memory::segment_manager>
+ > SV;
+
+ SV * sv_ptr = shmem.construct<SV>("my_object")();
for ( size_t i = 0 ; i < N ; ++i )
- (*sv_ptr)[i] = T(N - i);
+ sv_ptr->push_back(T(N - i));
std::sort(sv_ptr->begin(), sv_ptr->end());
for ( size_t i = 0 ; i < N ; ++i )
BOOST_CHECK((*sv_ptr)[i] == T(i + 1));
+ sv_ptr->assign(N/2, t);
+ for ( size_t i = 0 ; i < N/2 ; ++i )
+ BOOST_CHECK(sv_ptr->at(i) == t);
+
shmem.destroy_ptr(sv_ptr);
}
Modified: sandbox/static_vector/test/static_vector_test.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector_test.cpp (original)
+++ sandbox/static_vector/test/static_vector_test.cpp 2013-01-02 15:01:54 EST (Wed, 02 Jan 2013)
@@ -34,6 +34,16 @@
#include "static_vector_test.hpp"
+template <typename V>
+struct bad_alloc_strategy /*bad_alloc_null_allocator*/
+ : public static_vector_detail::default_strategy<V>
+{
+ static void allocate_failed()
+ {
+ BOOST_THROW_EXCEPTION(std::bad_alloc());
+ }
+};
+
template <typename T, size_t N>
void test_ctor_ndc()
{
@@ -419,16 +429,6 @@
#endif
}
-template <typename V>
-struct bad_alloc_strategy
- : public static_vector_detail::default_strategy<V>
-{
- static void allocate_failed()
- {
- BOOST_THROW_EXCEPTION(std::bad_alloc());
- }
-};
-
template <typename T>
void test_capacity_0_nd()
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk