Additional vector speed improvements, added basic benchmark against varray

[SVN r83126]
This commit is contained in:
Ion Gaztañaga committed 2013-02-24 13:13:36 +00:00
1 parent b3d5f6480b
commit 0896d04ddf
19 files changed
+5296 -924

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ rule test_all
for local fileb in [ glob *.cpp ]
{
all_rules += [ run $(fileb)
all_rules += [ run $(fileb) /boost/timer//boost_timer /boost/system//boost_system /boost/thread//boost_thread
: # additional args
: # test-files
: # requirements
-92
View File
@@ -1,92 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2009.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/move for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_MOVE_TEST_MOVABLE_HPP
#define BOOST_MOVE_TEST_MOVABLE_HPP
//[movable_definition
//header file "movable.hpp"
#include <boost/move/move.hpp>
//A movable class
class movable
{
BOOST_MOVABLE_BUT_NOT_COPYABLE(movable)
int value_;
public:
movable() : value_(1){}
//Move constructor and assignment
movable(BOOST_RV_REF(movable) m)
{ value_ = m.value_; m.value_ = 0; }
movable & operator=(BOOST_RV_REF(movable) m)
{ value_ = m.value_; m.value_ = 0; return *this; }
bool moved() const //Observer
{ return value_ == 0; }
};
class copy_movable
{
BOOST_COPYABLE_AND_MOVABLE(copy_movable)
int value_;
public:
copy_movable(int value = 1) : value_(value){}
//Move constructor and assignment
copy_movable(BOOST_RV_REF(copy_movable) m)
{ value_ = m.value_; m.value_ = 0; }
copy_movable(const copy_movable &m)
{ value_ = m.value_; }
copy_movable & operator=(BOOST_RV_REF(copy_movable) m)
{ value_ = m.value_; m.value_ = 0; return *this; }
copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m)
{ value_ = m.value_; return *this; }
bool moved() const //Observer
{ return value_ == 0; }
bool operator==(const copy_movable& m) const
{ return value_ == m.value_; }
};
struct copy_movable_wrapper
{
copy_movable cm;
};
copy_movable produce()
{ return copy_movable(); }
namespace boost{
template<>
struct has_nothrow_move<movable>
{
static const bool value = true;
};
template<>
struct has_nothrow_move<copy_movable>
{
static const bool value = true;
};
} //namespace boost{
//]
#endif //BOOST_MOVE_TEST_MOVABLE_HPP
+60 -37
View File
@@ -53,23 +53,26 @@ class movable_int
movable_int & operator= (int i)
{ this->m_int = i; return *this; }
bool operator ==(const movable_int &mi) const
{ return this->m_int == mi.m_int; }
~movable_int()
{ this->m_int = 0; }
bool operator !=(const movable_int &mi) const
{ return this->m_int != mi.m_int; }
friend bool operator ==(const movable_int &l, const movable_int &r)
{ return l.m_int == r.m_int; }
bool operator <(const movable_int &mi) const
{ return this->m_int < mi.m_int; }
friend bool operator !=(const movable_int &l, const movable_int &r)
{ return l.m_int != r.m_int; }
bool operator <=(const movable_int &mi) const
{ return this->m_int <= mi.m_int; }
friend bool operator <(const movable_int &l, const movable_int &r)
{ return l.m_int < r.m_int; }
bool operator >=(const movable_int &mi) const
{ return this->m_int >= mi.m_int; }
friend bool operator <=(const movable_int &l, const movable_int &r)
{ return l.m_int <= r.m_int; }
bool operator >(const movable_int &mi) const
{ return this->m_int > mi.m_int; }
friend bool operator >=(const movable_int &l, const movable_int &r)
{ return l.m_int >= r.m_int; }
friend bool operator >(const movable_int &l, const movable_int &r)
{ return l.m_int > r.m_int; }
int get_int() const
{ return m_int; }
@@ -84,6 +87,9 @@ class movable_int
int m_int;
};
inline movable_int produce_movable_int()
{ return movable_int(); }
template<class E, class T>
std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, movable_int const & p)
@@ -93,7 +99,6 @@ std::basic_ostream<E, T> & operator<<
return os;
}
template<>
struct is_copyable<movable_int>
{
@@ -121,6 +126,9 @@ class movable_and_copyable_int
: m_int(mmi.m_int)
{ mmi.m_int = 0; }
~movable_and_copyable_int()
{ this->m_int = 0; }
movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi)
{ this->m_int = mi.m_int; return *this; }
@@ -130,23 +138,23 @@ class movable_and_copyable_int
movable_and_copyable_int & operator= (int i)
{ this->m_int = i; return *this; }
bool operator ==(const movable_and_copyable_int &mi) const
{ return this->m_int == mi.m_int; }
friend bool operator ==(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int == r.m_int; }
bool operator !=(const movable_and_copyable_int &mi) const
{ return this->m_int != mi.m_int; }
friend bool operator !=(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int != r.m_int; }
bool operator <(const movable_and_copyable_int &mi) const
{ return this->m_int < mi.m_int; }
friend bool operator <(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int < r.m_int; }
bool operator <=(const movable_and_copyable_int &mi) const
{ return this->m_int <= mi.m_int; }
friend bool operator <=(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int <= r.m_int; }
bool operator >=(const movable_and_copyable_int &mi) const
{ return this->m_int >= mi.m_int; }
friend bool operator >=(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int >= r.m_int; }
bool operator >(const movable_and_copyable_int &mi) const
{ return this->m_int > mi.m_int; }
friend bool operator >(const movable_and_copyable_int &l, const movable_and_copyable_int &r)
{ return l.m_int > r.m_int; }
int get_int() const
{ return m_int; }
@@ -161,6 +169,9 @@ class movable_and_copyable_int
int m_int;
};
inline movable_and_copyable_int produce_movable_and_copyable_int()
{ return movable_and_copyable_int(); }
template<class E, class T>
std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, movable_and_copyable_int const & p)
@@ -194,23 +205,29 @@ class copyable_int
copyable_int & operator= (int i)
{ this->m_int = i; return *this; }
bool operator ==(const copyable_int &mi) const
{ return this->m_int == mi.m_int; }
copyable_int & operator= (const copyable_int &ci)
{ this->m_int = ci.m_int; return *this; }
bool operator !=(const copyable_int &mi) const
{ return this->m_int != mi.m_int; }
~copyable_int()
{ this->m_int = 0; }
bool operator <(const copyable_int &mi) const
{ return this->m_int < mi.m_int; }
friend bool operator ==(const copyable_int &l, const copyable_int &r)
{ return l.m_int == r.m_int; }
bool operator <=(const copyable_int &mi) const
{ return this->m_int <= mi.m_int; }
friend bool operator !=(const copyable_int &l, const copyable_int &r)
{ return l.m_int != r.m_int; }
bool operator >=(const copyable_int &mi) const
{ return this->m_int >= mi.m_int; }
friend bool operator <(const copyable_int &l, const copyable_int &r)
{ return l.m_int < r.m_int; }
bool operator >(const copyable_int &mi) const
{ return this->m_int > mi.m_int; }
friend bool operator <=(const copyable_int &l, const copyable_int &r)
{ return l.m_int <= r.m_int; }
friend bool operator >=(const copyable_int &l, const copyable_int &r)
{ return l.m_int >= r.m_int; }
friend bool operator >(const copyable_int &l, const copyable_int &r)
{ return l.m_int > r.m_int; }
int get_int() const
{ return m_int; }
@@ -225,6 +242,9 @@ class copyable_int
int m_int;
};
inline copyable_int produce_copyable_int()
{ return copyable_int(); }
template<class E, class T>
std::basic_ostream<E, T> & operator<<
(std::basic_ostream<E, T> & os, copyable_int const & p)
@@ -254,6 +274,9 @@ class non_copymovable_int
: m_int(a)
{}
~non_copymovable_int()
{ m_int = 0; }
bool operator ==(const non_copymovable_int &mi) const
{ return this->m_int == mi.m_int; }
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -14,7 +14,7 @@
#include <boost/container/static_vector.hpp>
#include <boost/shared_ptr.hpp>
#include "movable.hpp"
#include "movable_int.hpp"
using namespace boost::container;
+6 -1
View File
@@ -216,7 +216,12 @@ int vector_test()
stdvector->push_back(int(1));
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
}
{ //push_back with enough capacity
{ //test back()
const IntType test_this(1);
if(test_this != boostvector->back()) return 1;
}
{ //pop_back with enough capacity
boostvector->pop_back();
boostvector->pop_back();
stdvector->pop_back();