Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63378 - in sandbox/intro/boost: . intro intro/detail
From: strasser_at_[hidden]
Date: 2010-06-27 06:51:51


Author: stefans
Date: 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
New Revision: 63378
URL: http://svn.boost.org/trac/boost/changeset/63378

Log:
initial
Added:
   sandbox/intro/boost/
   sandbox/intro/boost/intro/
   sandbox/intro/boost/intro/apply.hpp (contents, props changed)
   sandbox/intro/boost/intro/apply_binary.hpp (contents, props changed)
   sandbox/intro/boost/intro/apply_recursive.hpp (contents, props changed)
   sandbox/intro/boost/intro/array_extension.hpp (contents, props changed)
   sandbox/intro/boost/intro/char_archive.hpp (contents, props changed)
   sandbox/intro/boost/intro/container.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/
   sandbox/intro/boost/intro/detail/auto_buckets.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/auto_buffer.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/complement.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/ebco_container.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/flat_map.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/has_complement_operator.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/immutable_iterator.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/indent_streambuf.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/map_insert_view.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/optional_map.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/optional_set.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/pool.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/pooled_map.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/pooled_set.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/pooled_unordered_map.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/pooled_unordered_set.hpp (contents, props changed)
   sandbox/intro/boost/intro/detail/set_insert_view.hpp (contents, props changed)
   sandbox/intro/boost/intro/dispatch_polymorphic.hpp (contents, props changed)
   sandbox/intro/boost/intro/introspect.hpp (contents, props changed)
   sandbox/intro/boost/intro/memory_archive.hpp (contents, props changed)
   sandbox/intro/boost/intro/move.hpp (contents, props changed)
   sandbox/intro/boost/intro/print.hpp (contents, props changed)
   sandbox/intro/boost/intro/reference.hpp (contents, props changed)
   sandbox/intro/boost/intro/register_class.hpp (contents, props changed)
   sandbox/intro/boost/intro/reset_shared.hpp (contents, props changed)
   sandbox/intro/boost/intro/semantics.hpp (contents, props changed)
   sandbox/intro/boost/intro/serialize.hpp (contents, props changed)
   sandbox/intro/boost/intro/vector.hpp (contents, props changed)

Added: sandbox/intro/boost/intro/apply.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/apply.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,68 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_APPLY_HPP
+#define BOOST_INTRO_APPLY_HPP
+
+#include <boost/intro/introspect.hpp>
+#include <boost/intro/detail/has_complement_operator.hpp>
+#include <boost/intro/detail/complement.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/utility/enable_if.hpp>
+
+
+namespace boost{
+namespace intro{
+namespace detail{
+template<class,class>
+struct applier;
+}
+
+template<class F,class T>
+void apply(F const &f,T &t){
+ intro::for_each_local<T>(detail::applier<F,T>(f,t));
+}
+
+
+namespace detail{
+
+template<class F,class Class,class T,T Class::*Ptr,class Semantics>
+void apply(F const &f,Class &c,
+ member_t<typename remove_const<Class>::type,T,Ptr,Semantics>){
+ f(c.*Ptr,Semantics());
+}
+
+template<class F,class Class,class Base>
+void apply(F const &f,Class &c,base_class<Base>){
+ typename mpl::if_<is_const<Class>,Base const,Base>::type &base=c;
+ using intro::apply;
+ apply(f,base); //recurse into base classes
+}
+
+template<class F,class Class>
+struct applier{
+ applier(F const &f,Class &c) : f(f),c(c){}
+ typedef void result_type;
+ template<class Local>
+ void operator()(Local local) const{
+ apply(f,c,local);
+ }
+ applier<complement<F>,Class> operator~() const{
+ return applier<complement<F>,Class>(complement<F>(f),c);
+ }
+private:
+ F const f;
+ Class &c;
+};
+
+template<class F,class Class>
+struct has_complement_operator<applier<F,Class> >
+ : has_complement_operator<F>{};
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/apply_binary.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/apply_binary.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,73 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_APPLY_BINARY_HPP
+#define BOOST_INTRO_APPLY_BINARY_HPP
+
+#include <boost/intro/introspect.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/bind.hpp>
+#include <boost/intro/detail/complement.hpp>
+#include <boost/intro/detail/has_complement_operator.hpp>
+
+
+namespace boost{
+namespace intro{
+namespace detail{
+template<class,class,class>
+struct binary_applier;
+}
+
+template<class F,class T,class T2>
+void apply_binary(F const &f,T &t,T2 &t2){
+ T const &t2const=t2; (void)t2const;//T and T2 must only differ in const-ness
+ T2 const &t1const=t; (void)t1const;
+ intro::for_each_local<T>(detail::binary_applier<F,T,T2>(f,t,t2));
+}
+
+
+namespace detail{
+
+template<class F,class Class,class Class2,class T,T Class::*Ptr,class Semantics>
+void apply_binary(F const &f,Class &c,Class2 &c2,
+ member_t<typename remove_const<Class>::type,T,Ptr,Semantics>){
+ f(c.*Ptr,c2.*Ptr,Semantics());
+}
+
+template<class F,class Class,class Class2,class Base>
+void apply_binary(F const &f,Class &c,Class2 &c2,base_class<Base>){
+ typename mpl::if_<is_const<Class>,Base const,Base>::type &base=c;
+ typename mpl::if_<is_const<Class2>,Base const,Base>::type &base2=c2;
+ using intro::apply_binary;
+ apply_binary(f,base,base2); //recurse into base classes
+}
+
+template<class F,class T,class T2>
+struct binary_applier{
+ binary_applier(F const &f,T &t,T2 &t2) : f(f),t(t),t2(t2){}
+ typedef void result_type;
+ template<class Local>
+ void operator()(Local local) const{
+ apply_binary(f,t,t2,local);
+ }
+ binary_applier<complement<F>,T,T2> operator~() const{
+ return binary_applier<complement<F>,T,T2>(complement<F>(f),t,t2);
+ }
+private:
+ F const f;
+ T &t;
+ T2 &t2;
+};
+
+template<class F,class T,class T2>
+struct has_complement_operator<binary_applier<F,T,T2> >
+ : has_complement_operator<F>{};
+
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/apply_recursive.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/apply_recursive.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,182 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_APPLY_RECURSIVE_HPP
+#define BOOST_INTRO_APPLY_RECURSIVE_HPP
+
+#include <boost/intro/apply.hpp>
+#include <boost/intro/dispatch_polymorphic.hpp>
+#include <boost/intro/detail/pooled_unordered_set.hpp>
+#include <boost/intro/detail/optional_set.hpp>
+#include <boost/intro/detail/set_insert_view.hpp>
+
+namespace boost{
+namespace intro{
+
+template<class Set>
+class apply_recursive_data{
+public:
+ explicit apply_recursive_data(Set &set) : applied(set){}
+ template<class T>
+ bool register_applied_object(T const &t){
+ return applied.insert(&t).second;
+ }
+ template<class T>
+ bool deregister_applied_object(T const &t){
+ return applied.erase(&t) > 0;
+ }
+private:
+ Set &applied;
+};
+
+namespace detail{
+
+template<class Base>
+class apply_recursive_data_invert_view{
+public:
+ explicit apply_recursive_data_invert_view(Base &base) : base(base){}
+ template<class T>
+ bool register_applied_object(T const &t){
+ return base.unregister_applied_object(t);
+ }
+ template<class T>
+ bool deregister_applied_object(T const &t){
+ return base.register_applied_object(t);
+ }
+private:
+ Base &base;
+};
+
+}
+
+template<class F,class Data,class T,class Semantics>
+void apply_member_recursive(F const &f,Data &data,T &t,Semantics){
+ detail::apply_member_recursive(f,data,t,Semantics(),
+ typename mpl::has_key<typename Semantics::set,polymorphic>::type(),
+ typename mpl::has_key<typename Semantics::set,shared>::type());
+}
+
+namespace detail{
+
+template<class F,class Data,class T,class Semantics,bool Shared>
+void apply_member_recursive(F const &f,Data &data,T &t,Semantics,mpl::true_ poly,mpl::bool_<Shared>){
+ dispatch_polymorphic(
+ bind(
+ detail::recursive_member_applier<F,Data>(f,data),
+ _1,
+ Semantics(),
+ mpl::false_(),
+ mpl::bool_<Shared>()
+ ),t);
+}
+template<class F,class Data,class T,class Semantics>
+void apply_member_recursive(F const &f,Data &data,T &t,Semantics,mpl::false_ poly,mpl::true_ shared_){
+ if(data.register_applied_object(t))
+ detail::apply_member_recursive(f,data,t,Semantics(),poly,mpl::false_());
+}
+template<class F,class Data,class T,class Semantics>
+void apply_member_recursive(F const &f,Data &data,T &t,Semantics,mpl::false_ poly,mpl::false_ shared_){
+ f(t,Semantics()); //TODO sollte das bei undo-en nach apply_recursive passieren?
+ apply_recursive(f,data,t,Semantics());
+}
+
+template<class F,class Data>
+struct recursive_member_applier{
+ typedef void result_type;
+ recursive_member_applier(F const &f,Data &data) : f(f),data(data){}
+ template<class T,class Semantics>
+ void operator()(T &t,Semantics) const{
+ intro::apply_member_recursive(f,data,t,Semantics());
+ }
+ template<class T,class Semantics,bool Poly,bool Shared>
+ void operator()(T &t,Semantics,mpl::bool_<Poly> poly,mpl::bool_<Shared> sha) const{
+ detail::apply_member_recursive(f,data,t,Semantics(),poly,sha);
+ }
+ recursive_member_applier<complement<F>,apply_recursive_data_invert_view<Data> >
+ operator~() const{
+ return recursive_member_applier<complement<F>,apply_recursive_data_invert_view<Data> >
+ (complement<F>(f),apply_recursive_data_invert_view<Data>(data));
+ }
+private:
+ F const f;
+ Data &data;
+};
+
+template<class F,class Data>
+struct has_complement_operator<recursive_member_applier<F,Data> >
+ : has_complement_operator<F>{};
+
+template<class F,class Data,class T>
+void apply_recursive_class(F const &f,Data &data,T &t,mpl::true_ is_class_){
+ using intro::apply;
+ apply(detail::recursive_member_applier<F,Data>(f,data),t);
+}
+
+template<class F,class Data,class T>
+void apply_recursive_class(F const &f,Data &data,T &t,mpl::false_ is_class_){}
+
+
+template<class F,class Data,class T,class Semantics>
+void apply_recursive(F const &f,Data &data,T *&t,Semantics){
+ if(t) intro::apply_member_recursive(f,data,*t,typename Semantics::indir_semantics());
+}
+
+template<class F,class Data,class T,class Semantics>
+void apply_recursive(F const &f,Data &data,T * const &t,Semantics){
+ if(t) intro::apply_member_recursive(f,data,*t,typename Semantics::indir_semantics());
+}
+
+template<class F,class Data,class T,class Semantics>
+void apply_recursive(F const &f,Data &data,reference<T> &t,Semantics){
+ intro::apply_member_recursive(f,data,t.get(),typename Semantics::indir_semantics());
+}
+template<class F,class Data,class T,class Semantics>
+void apply_recursive(F const &f,Data &data,reference<T> const &t,Semantics){
+ intro::apply_member_recursive(f,data,t.get(),typename Semantics::indir_semantics());
+}
+
+template<class F,class T,class Semantics>
+void apply_recursive(F const &f,T &t,Semantics,mpl::false_ shared){
+ typedef detail::optional_set<detail::pooled_unordered_set<void const *,4> > set_type;
+ set_type set;
+ apply_recursive_data<set_type> data(set);
+ apply_recursive(f,data,t,Semantics());
+}
+
+template<class F,class T,class Semantics>
+void apply_recursive(F const &f,T &t,Semantics,mpl::true_ shared){
+ typedef detail::optional_set<detail::pooled_unordered_set<void const *,4> > oset_type;
+ oset_type oset;
+ typedef detail::set_insert_view<oset_type> set_type;
+ set_type set(oset,&t);
+ apply_recursive_data<set_type> data(set);
+ apply_recursive(f,data,t,Semantics());
+}
+
+
+}
+
+template<class F,class Data,class T,class Semantics>
+void apply_recursive(F const &f,Data &data,T &t,Semantics){
+ detail::apply_recursive_class(f,data,t,typename is_class<T>::type());
+}
+
+
+template<class F,class T,class Semantics>
+void apply_recursive(F const &f,T &t,Semantics){
+ detail::apply_recursive(f,t,Semantics(),typename mpl::has_key<typename Semantics::set,shared>::type());
+}
+
+
+template<class F,class T>
+void apply_recursive(F const &f,T &t){
+ apply_recursive(f,t,typename default_semantics<T>::type());
+}
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/array_extension.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/array_extension.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,83 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_ARRAY_EXTENSION_HPP
+#define BOOST_INTRO_ARRAY_EXTENSION_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/is_pod.hpp>
+#include <iterator>
+#include <algorithm>
+
+namespace boost{
+namespace intro{
+
+template<class T>
+struct array_extension : mpl::false_{};
+
+template<class T>
+struct continuous_values : mpl::false_{};
+
+template<class T>
+struct continuous_values<T *> : mpl::true_{};
+
+
+template<typename Vector>
+class vector_back_insert_iterator
+ : public std::iterator<std::output_iterator_tag,void,void,void,void>{
+public:
+ typedef Vector container_type;
+ explicit vector_back_insert_iterator(Vector &vec) : vec(vec){}
+ vector_back_insert_iterator &operator=(typename Vector::const_reference v){
+ this->vec.push_back(v);
+ return *this;
+ }
+ template<class InputIterator,class Size>
+ vector_back_insert_iterator &assign(InputIterator it,Size size){
+ this->assign(it,size,
+ typename array_extension<Vector>::type(),
+ mpl::bool_<is_pod<typename Vector::value_type>::type::value
+ && continuous_values<InputIterator>::type::value>()
+ );
+ return *this;
+ }
+ vector_back_insert_iterator &operator*(){ return *this; }
+ vector_back_insert_iterator &operator++(){ return *this; }
+ vector_back_insert_iterator operator++(int){ return *this; }
+ vector_back_insert_iterator operator+=(std::size_t){ return *this; }
+private:
+ template<class Iterator,class Size,bool Pod>
+ void assign(Iterator it,Size size,mpl::true_ array,mpl::bool_<Pod>){
+ this->vec.push_back(it,size);
+ }
+ template<class Iterator,class Size>
+ void assign(Iterator it,Size size,mpl::false_ array,mpl::true_ pod){
+ std::size_t const oldsize=this->vec.size();
+ this->vec.resize(oldsize + size);
+ std::memcpy(&this->vec[oldsize],&*it,size * sizeof(typename Vector::value_type));
+ }
+ template<class Iterator,class Size>
+ void assign(Iterator it,Size size,mpl::false_ array,mpl::false_ pod){
+ std::size_t const oldsize=this->vec.size();
+ this->vec.resize(oldsize + size);
+ for(std::size_t c=0;c<size;++c)
+ vec[oldsize+c]=*it++;
+ }
+
+ Vector &vec;
+};
+
+
+template<class Vector>
+struct array_extension<vector_back_insert_iterator<Vector> > : mpl::true_{};
+
+
+
+}
+}
+
+
+
+#endif

Added: sandbox/intro/boost/intro/char_archive.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/char_archive.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,101 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+
+#ifndef BOOST_INTRO_CHAR_ARCHIVE_HPP
+#define BOOST_INTRO_CHAR_ARCHIVE_HPP
+
+
+#include <boost/mpl/bool.hpp>
+#include <boost/serialization/is_bitwise_serializable.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/intro/array_extension.hpp>
+#include <algorithm>
+#include <boost/mpl/size_t.hpp>
+#include <iterator>
+#include <boost/archive/archive_exception.hpp>
+#include <cstring>
+
+namespace boost{
+namespace intro{
+
+template<class OutputIterator>
+class char_oarchive{
+public:
+ explicit char_oarchive(OutputIterator const &out) : out(out){}
+ template<class Size>
+ void save_binary(void const *vdata,Size size){
+ this->save_binary(static_cast<char const *>(vdata),size,typename array_extension<OutputIterator>::type());
+ }
+ template<class T>
+ char_oarchive &operator<<(T const &t){
+ BOOST_STATIC_ASSERT(serialization::is_bitwise_serializable<T>::value);
+ this->save_binary(&t,mpl::size_t<sizeof(T)>());
+ return *this;
+ }
+private:
+ template<class Size>
+ void save_binary(char const *data,Size size,mpl::true_){
+ this->out.assign(data,size);
+ }
+ template<class Size>
+ void save_binary(char const *data,Size size,mpl::false_){
+ std::copy(data,data+size,this->out);
+ }
+
+ OutputIterator out;
+};
+
+template<class InputIterator>
+class char_iarchive{
+public:
+ char_iarchive(InputIterator const &begin,InputIterator const &end)
+ : in(begin), end(end){}
+ template<class Size>
+ void load_binary(void *vdata,Size size){
+ char *data=static_cast<char *>(vdata);
+ this->load_binary(
+ data,
+ size,
+ typename std::iterator_traits<InputIterator>::iterator_category(),
+ typename continuous_values<InputIterator>::type()
+ );
+ }
+ template<class T>
+ char_iarchive &operator >>(T &t){
+ BOOST_STATIC_ASSERT(serialization::is_bitwise_serializable<T>::value);
+ this->load_binary(&t,mpl::size_t<sizeof(T)>());
+ return *this;
+ }
+private:
+ template<class Size>
+ void load_binary(char *data,Size size,std::random_access_iterator_tag,mpl::true_ contvals){
+ if(this->in + size > this->end) throw archive::archive_exception(archive::archive_exception::stream_error);
+ std::memcpy(data,&*this->in,size);
+ this->in+=size;
+ }
+ template<class Size>
+ void load_binary(char *data,Size size,std::random_access_iterator_tag,mpl::false_ contvals){
+ if(this->in + size > this->end) throw archive::archive_exception(archive::archive_exception::stream_error);
+ std::copy(data,data+size,this->in);
+ }
+ template<class Size,class Category>
+ void load_binary(char *data,Size size,Category,mpl::false_ contvals){
+ for(std::size_t c=0;c<size;++c){
+ if(this->in == this->end) throw archive::archive_exception(archive::archive_exception::stream_error);
+ *data++=*this->in++;
+ }
+ }
+
+ InputIterator in;
+ InputIterator end;
+};
+
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/container.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/container.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,62 @@
+#ifndef BOOST_INTRO_CONTAINER_HPP
+#define BOOST_INTRO_CONTAINER_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/intro/detail/indent_streambuf.hpp>
+#include <ostream>
+
+namespace boost{
+namespace intro{
+
+
+template<class F,class Data,class Container,class Semantics>
+void container_apply_recursive(F const &f,Data &data,Container &c,Semantics){
+ typedef typename mpl::if_<
+ is_const<Container>,
+ typename Container::const_iterator,
+ typename Container::iterator>::type iterator;
+ for(iterator it=c.begin();it != c.end();++it){
+ intro::apply_member_recursive(f,data,*it,typename Semantics::indir_semantics());
+ }
+}
+
+template<class Archive,class Data,class Container,class Semantics>
+void container_serialize(Archive &ar,Data &data,Container const &c,Semantics){
+ ar << c.size();
+ for(typename Container::const_iterator it=c.begin();it != c.end();++it){
+ intro::serialize_member(ar,data,*it,typename Semantics::indir_semantics());
+ }
+}
+
+template<class Map,class Container,class Semantics>
+void container_move(Map &,Container &src,Container &dest,Semantics){
+ new (&dest) Container();
+ src.swap(dest);
+ src.~Container();
+}
+
+template<class Container>
+void container_copy_shallow(Container const &src,Container &dest){
+ new (&dest) Container(src);
+}
+
+template<class Container,class Transformation>
+void container_print(Container const &c,std::ostream &out,Transformation const &transform){
+ out << '{';
+ detail::indent_streambuf indent(*out.rdbuf(),false);
+ std::ostream indent_out(&indent);
+ for(typename Container::const_iterator it=c.begin();it != c.end();){
+ print(*it,indent_out,transform);
+ if(++it != c.end()) indent_out << ", ";
+ }
+ out << '}';
+}
+
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/auto_buckets.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/auto_buckets.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,46 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_AUTO_BUCKETS_HPP
+#define BOOST_INTRO_DETAIL_AUTO_BUCKETS_HPP
+
+#include <boost/scoped_array.hpp>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+
+template<class Container,std::size_t Initial,std::size_t GrowthFactor=2>
+class auto_buckets{
+ typedef typename Container::bucket_traits bucket_traits;
+ typedef typename Container::bucket_type bucket_type;
+public:
+ bucket_traits initial_traits(){
+ return bucket_traits(this->initial,Initial);
+ }
+ void rehash(Container &container){
+ //keep a maximum load factor of 1.0
+ std::size_t const bucketscount=container.bucket_count();
+ if(container.size() > bucketscount){
+ std::size_t const newbucketscount=bucketscount * GrowthFactor;
+ bucket_type *newbuckets=
+ new bucket_type[newbucketscount];
+ container.rehash(
+ bucket_traits(newbuckets,newbucketscount)
+ ); //nothrow
+ allocated.reset(newbuckets);
+ }
+ }
+private:
+ bucket_type initial[Initial];
+ scoped_array<bucket_type> allocated;
+};
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/detail/auto_buffer.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/auto_buffer.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,225 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_AUTO_BUFFER_HPP
+#define BOOST_INTRO_DETAIL_AUTO_BUFFER_HPP
+
+#include <boost/type_traits/is_pod.hpp>
+#include <boost/intro/array_extension.hpp>
+#include <cstring>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Derived,class T>
+class vector_facade{
+public:
+ typedef T value_type;
+ typedef T *iterator;
+ typedef T const *const_iterator;
+ typedef T &reference;
+ typedef T const &const_reference;
+ iterator begin(){ return that().data(); }
+ const_iterator begin() const{ return that().data(); }
+ iterator end(){ return that().data() + that().size(); }
+ const_iterator end() const{ return that().data() + that().size(); }
+
+ reference operator[](std::size_t n){ return *(begin()+n); }
+ const_reference operator[](std::size_t n) const{ return *(begin()+n); }
+ bool empty() const{ return begin() == end(); }
+ reference back(){ return *(end()-1); }
+ const_reference back() const{ return *(end()-1); }
+
+ void reserve(std::size_t n){
+ if(that().capacity() < n){
+ that().grow(n);
+ }
+ BOOST_ASSERT(that().capacity() >= n);
+ }
+ void push_back(const_reference x){
+ reserve(that().size() + 1);
+ new (end()) value_type(x);
+ that().size(that().size() + 1);
+ }
+ void resize(std::size_t n,const_reference x=value_type()){
+ reserve(n);
+ if(n > that().size()) construct(end(),begin() + n,x);
+ else destruct(begin() + n,end());
+ that().size(n);
+ }
+ void clear(){
+ destruct(begin(),end());
+ that().size(0);
+ }
+ //extension:
+ template<class InPlaceFactory>
+ void push_back(InPlaceFactory const &fac){
+ reserve(that().size() + 1);
+ fac.template apply<T>(end());
+ that().size(that().size() + 1);
+ }
+ template<class Iterator,class Size>
+ void push_back(Iterator it,Size size){
+ std::size_t const newsize=that().size()+size;
+ reserve(newsize);
+ construct_n(end(),it,size);
+ that().size(newsize);
+ }
+protected:
+ void destruct(){
+ destruct(begin(),end());
+ }
+ static void destruct(const_iterator it,const_iterator end){
+ for(;it != end;++it) it->~T();
+ }
+ static void construct(iterator begin,iterator end,const_reference x){
+ iterator it=begin;
+ try{
+ for(;it != end;++it) new (it) T();
+ }catch(...){
+ destruct(begin,it);
+ throw;
+ }
+ }
+ static void construct(iterator outbegin,const_iterator begin,const_iterator end){
+ iterator out=outbegin;
+ try{
+ for(const_iterator it=begin;it != end;++it,++out)
+ new (out) T(*it);
+ }catch(...){
+ destruct(outbegin,out);
+ throw;
+ }
+ }
+ template<class Iterator,class Size>
+ static void construct_n(T *dest,Iterator it,Size n){
+ construct_n(dest,it,n,
+ mpl::bool_<is_pod<T>::type::value
+ && intro::continuous_values<Iterator>::type::value>());
+ }
+ template<class Iterator,class Size>
+ static void construct_n(T *dest,Iterator it,Size n,mpl::true_ pod){
+ std::memcpy(dest,&*it,sizeof(T)*std::size_t(n));
+ }
+ template<class Iterator,class Size>
+ static void construct_n(T *dest,Iterator it,Size n,mpl::false_ pod){
+ std::size_t c;
+ try{
+ for(c=0;c<n;++c){
+ new (dest+c) T(*it++);
+ }
+ }catch(...){
+ destruct(dest,dest+c);
+ throw;
+ }
+ }
+private:
+ Derived &that(){ return static_cast<Derived &>(*this); }
+ Derived const &that() const{ return static_cast<Derived const &>(*this); }
+};
+
+template<class T,std::size_t Embed>
+class auto_buffer
+ : public vector_facade<auto_buffer<T,Embed>,T>{
+ typedef vector_facade<auto_buffer,T> base_type;
+public:
+ auto_buffer()
+ : data_(emb_data())
+ , size_(0)
+ , capacity_(Embed){}
+ ~auto_buffer(){
+ base_type::destruct();
+ if(data_ != emb_data()) ::operator delete(data_);
+ }
+ T *data() const{ return data_; }
+ std::size_t size() const{ return size_; }
+ void size(std::size_t n){ size_=n; }
+ std::size_t capacity() const{ return capacity_; }
+
+ void grow(std::size_t n){
+ std::size_t newcap=capacity() * 2;
+ if(n > newcap) newcap=n;
+ T *newdata=
+ reinterpret_cast<T *>(::operator new(newcap * sizeof(T)));
+ try{
+ base_type::construct(newdata,this->begin(),this->end());
+ }catch(...){
+ ::operator delete(newdata);
+ throw;
+ }
+ base_type::destruct(this->begin(),this->end());
+ this->capacity_=newcap;
+ if(data_ != emb_data()) ::operator delete(data_);
+ this->data_=newdata;
+ }
+private:
+ T *emb_data(){
+ return reinterpret_cast<T *>(this->emb_data_);
+ }
+ char emb_data_[sizeof(T) * Embed];
+ T *data_;
+ std::size_t size_;
+ std::size_t capacity_;
+};
+
+template<class T,std::size_t Capacity>
+class static_buffer
+ : public vector_facade<static_buffer<T,Capacity>,T>{
+ typedef vector_facade<static_buffer,T> base_type;
+public:
+ static_buffer() : size_(0){}
+ T *data() const{ return emb_data(); }
+ std::size_t size() const{ return size_; }
+ void size(std::size_t n){ size_=n; }
+ std::size_t capacity() const{ return Capacity; }
+
+ void grow(std::size_t){
+ BOOST_ASSERT(false);
+ }
+private:
+ T *emb_data() const{
+ return const_cast<T *>(reinterpret_cast<T const *>(this->emb_data_));
+ }
+ char emb_data_[sizeof(T) * Capacity];
+ std::size_t size_;
+};
+
+template<class T>
+class vector_view
+ : public vector_facade<vector_view<T>,T>{
+ typedef vector_facade<vector_view,T> base_type;
+public:
+ vector_view(T *data,std::size_t &size,std::size_t capacity)
+ : data_(data)
+ , size_(size)
+ , capacity_(capacity){}
+ T *data() const{ return data_; }
+ std::size_t size() const{ return size_; }
+ void size(std::size_t n){ size_=n; }
+ std::size_t capacity() const{ return capacity_; }
+ void grow(std::size_t){
+ BOOST_ASSERT(false);
+ }
+private:
+ T *data_;
+ std::size_t &size_; //reference!
+ std::size_t capacity_;
+};
+
+
+}
+
+template<class T,std::size_t Embed>
+struct array_extension<detail::auto_buffer<T,Embed> >
+ : mpl::true_{};
+
+
+}
+}
+
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/complement.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/complement.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,85 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_COMPLEMENT_HPP
+#define BOOST_INTRO_DETAIL_COMPLEMENT_HPP
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class F>
+struct complement{
+ typedef void result_type;
+ //typedef typename F::result_type result_type;
+ explicit complement(F const &f) : f(f){}
+ template<class T0>
+ result_type operator()(T0 &t0) const{
+ return (~f)(t0);
+ }
+ template<class T0>
+ result_type operator()(T0 const &t0) const{
+ return (~f)(t0);
+ }
+ template<class T0,class T1>
+ result_type operator()(T0 const &t0,T1 const &t1) const{
+ return (~f)(t0,t1);
+ }
+ template<class T0,class T1>
+ result_type operator()(T0 &t0,T1 const &t1) const{
+ return (~f)(t0,t1);
+ }
+ template<class T0,class T1>
+ result_type operator()(T0 const &t0,T1 &t1) const{
+ return (~f)(t0,t1);
+ }
+ template<class T0,class T1>
+ result_type operator()(T0 &t0,T1 &t1) const{
+ return (~f)(t0,t1);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 const &t0,T1 const &t1,T2 const &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 &t0,T1 const &t1,T2 const &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 const &t0,T1 &t1,T2 const &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 const &t0,T1 const &t1,T2 &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 &t0,T1 &t1,T2 const &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 &t0,T1 const &t1,T2 &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 const &t0,T1 &t1,T2 &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+ template<class T0,class T1,class T2>
+ result_type operator()(T0 &t0,T1 &t1,T2 &t2) const{
+ return (~f)(t0,t1,t2);
+ }
+private:
+ F const &f;
+};
+
+
+}
+}
+}
+
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/ebco_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/ebco_container.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,58 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_EBCO_CONTAINER_HPP
+#define BOOST_INTRO_DETAIL_EBCO_CONTAINER_HPP
+
+#include <boost/type_traits/is_empty.hpp>
+#include <boost/swap.hpp>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class T,class Tag,bool empty>
+class ebco_container_base;
+
+template<class T,class Tag>
+class ebco_container_base<T,Tag,true>{
+protected:
+ ebco_container_base(){}
+ explicit ebco_container_base(T const &){}
+ T get() const{ return T(); }
+ void set(T const &){}
+ void swap(ebco_container_base &){}
+};
+
+template<class T,class Tag>
+class ebco_container_base<T,Tag,false>{
+protected:
+ ebco_container_base(){}
+ explicit ebco_container_base(T const &t) : t(t){}
+ T const &get() const{ return this->t; }
+ void set(T const &nt){ this->t=nt; }
+ void swap(ebco_container_base &rhs){
+ boost::swap(t,rhs.t);
+ }
+private:
+ T t;
+};
+
+template<class T,class Tag=void>
+class ebco_container
+ : protected ebco_container_base<T,Tag,is_empty<T>::value>{
+ typedef ebco_container_base<T,Tag,is_empty<T>::value> base_type;
+protected:
+ ebco_container(){}
+ explicit ebco_container(T const &t) : base_type(t){}
+};
+
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/flat_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/flat_map.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,94 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_FLAT_MAP_HPP
+#define BOOST_INTRO_DETAIL_FLAT_MAP_HPP
+
+#include <vector>
+#include <utility>
+#include <algorithm>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Iterator,class T,class Compare>
+Iterator find(Iterator it,Iterator end,T const &value,Compare const &comp){
+ it=std::lower_bound(it,end,value,comp);
+ if(it == end || comp(value,*it)) return end;
+ else return it;
+}
+
+template<class Key,class Mapped,class Compare=std::less<Key> >
+class flat_map{
+public:
+ typedef Key key_type;
+ typedef Mapped mapped_type;
+ typedef std::pair<key_type,mapped_type> value_type;
+ typedef std::vector<value_type> vector_type;
+ typedef typename vector_type::iterator iterator;
+ typedef typename vector_type::const_iterator const_iterator;
+ typedef value_type const &const_reference;
+
+ iterator begin(){ return vector.begin(); }
+ const_iterator begin() const{ return vector.begin(); }
+ iterator end(){ return vector.end(); }
+ const_iterator end() const{ return vector.end(); }
+ std::pair<iterator,bool>
+ insert(const_reference x){
+ value_comparer comp;
+ iterator it=std::lower_bound(
+ vector.begin(),
+ vector.end(),
+ x,
+ comp);
+ if(it == vector.end()){
+ vector.push_back(x);
+ return std::make_pair(vector.end()-1,true);
+ }else if(!comp(x,*it)) return std::make_pair(it,false);
+ else{
+ std::size_t pos=it-vector.begin();
+ vector.push_back(vector.back());
+ it=vector.begin()+pos;
+ std::copy_backward(
+ it,
+ vector.end()-2, //size() is at least 2
+ vector.end()-1);
+ *it=x;
+ return std::make_pair(it,true);
+ }
+ }
+ iterator find(key_type const &key){
+ return detail::find(
+ vector.begin(),
+ vector.end(),
+ std::make_pair(key,mapped_type()),
+ value_comparer()
+ );
+ }
+ const_iterator find(key_type const &key) const{
+ return detail::find(
+ vector.begin(),
+ vector.end(),
+ std::make_pair(key,mapped_type()),
+ value_comparer()
+ );
+ }
+private:
+ struct value_comparer{
+ bool operator()(const_reference l,const_reference r) const{
+ return Compare()(l.first,r.first);
+ }
+ };
+
+ vector_type vector;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/has_complement_operator.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/has_complement_operator.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,43 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_HAS_COMPLEMENT_OPERATOR_HPP
+#define BOOST_INTRO_DETAIL_HAS_COMPLEMENT_OPERATOR_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class T>
+struct has_complement_operator_helper : T{
+ operator int();
+};
+
+typedef char complement_yes;
+typedef int complement_no;
+
+template<class T>
+complement_yes complement_yesno(T const &);
+complement_no complement_yesno(int);
+
+
+template<class T>
+struct has_complement_operator
+ : mpl::bool_<
+ sizeof(complement_yesno(~(*((has_complement_operator_helper<T> *)0))))
+ == sizeof(complement_yes)
+ >{};
+
+}
+}
+}
+
+
+#endif
+

Added: sandbox/intro/boost/intro/detail/immutable_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/immutable_iterator.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,43 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_IMMUTABLE_ITERATOR_HPP
+#define BOOST_INTRO_DETAIL_IMMUTABLE_ITERATOR_HPP
+
+#include <iterator>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Iterator>
+class immutable_iterator{
+public:
+ typedef typename std::iterator_traits<Iterator>::value_type value_type;
+ typedef typename std::iterator_traits<Iterator>::reference reference;
+ typedef typename std::iterator_traits<Iterator>::pointer pointer;
+ immutable_iterator(Iterator const &it) : it(it){}
+ template<class Other>
+ immutable_iterator(immutable_iterator<Other> const &rhs) : it(rhs.it){}
+ reference operator*() const{ return *it; }
+ Iterator const &operator->() const{ return it; }
+ bool operator==(immutable_iterator const &rhs) const{
+ return it == rhs.it;
+ }
+ bool operator!=(immutable_iterator const &rhs) const{
+ return it != rhs.it;
+ }
+private:
+ template<class> friend class immutable_iterator;
+ Iterator it;
+};
+
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/indent_streambuf.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/indent_streambuf.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,50 @@
+#ifndef BOOST_INTRO_INDENT_STREAMBUF_HPP
+#define BOOST_INTRO_INDENT_STREAMBUF_HPP
+
+#include <streambuf>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+//TODO doesn't set pointers correctly on failure
+class indent_streambuf : public std::streambuf{
+ typedef std::streambuf base_type;
+public:
+ explicit indent_streambuf(std::streambuf &base,bool indent)
+ : base(base),indent(indent){}
+ virtual int overflow(int c){
+ if(!this->flush()) return EOF;
+ return this->write(c) ? c : EOF;
+ }
+ virtual int sync(){
+ return this->flush() ? 0 : -1;
+ }
+private:
+ bool write(char c){
+ if(this->indent){
+ if(base.sputn(" ",2) != 2) return false;
+ this->indent=false;
+ }
+ if(base.sputc(c) == EOF) return false;
+ if(c == '\n') this->indent=true;
+ return true;
+ }
+ bool flush(){
+ for(char *c=pbase();c != pptr();++c){
+ if(!this->write(*c)) return false;
+ }
+ setp(pbase(),pbase());
+ return true;
+ }
+
+ std::streambuf &base;
+ bool indent;
+};
+
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/detail/map_insert_view.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/map_insert_view.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,104 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_MAP_INSERT_VIEW_HPP
+#define BOOST_INTRO_DETAIL_MAP_INSERT_VIEW_HPP
+
+#include <boost/intro/detail/immutable_iterator.hpp>
+#include <boost/intro/detail/ebco_container.hpp>
+#include <boost/swap.hpp>
+#include <functional>
+#include <utility>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Map,class Equal=std::equal_to<typename Map::key_type> >
+class map_insert_view : public ebco_container<Equal>{
+ typedef ebco_container<Equal> eq;
+public:
+ typedef Equal key_equal;
+ typedef typename Map::key_type key_type;
+ typedef typename Map::mapped_type mapped_type;
+ typedef typename Map::value_type value_type;
+ typedef typename Map::reference reference;
+ typedef typename Map::const_reference const_reference;
+ typedef typename Map::pointer pointer;
+ typedef typename Map::const_pointer const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+ typedef typename Map::size_type size_type;
+ typedef typename Map::difference_type difference_type;
+
+ map_insert_view(Map &map,const_reference element,key_equal const &eq=key_equal())
+ : eq(eq),map(map),element(element){}
+
+ bool empty() const{ return false; }
+ size_type size() const{ return map.size() + 1; }
+ mapped_type &operator[](key_type const &x){
+ if(key_eq()(x,element.first)) return element.second;
+ else return map[x];
+ }
+ std::pair<iterator,bool> insert(const_reference x){
+ if(key_eq()(x.first,element.first)) return std::make_pair(iterator(&element),false);
+ else{
+ std::pair<typename Map::iterator,bool> ret=map.insert(x);
+ return std::make_pair(&*ret.first,ret.second);
+ }
+ }
+ iterator insert(iterator pos,const_reference x){ return insert(x).first; }
+ template<class InputIterator>
+ void insert(InputIterator b,InputIterator e){
+ for(;b != e;++b) insert(*b);
+ }
+ size_type erase(key_type const &x){
+ BOOST_ASSERT(!key_eq()(x,element.first));
+ return map.erase(x);
+ }
+ void swap(map_insert_view &rhs){
+ map.swap(rhs.map);
+ boost::swap(element,rhs.element);
+ eq::swap(*this);
+ }
+ iterator find(key_type const &x){
+ if(key_eq()(x,element.first)) return iterator(&element);
+ else return &*map.find(x);
+ }
+ const_iterator find(key_type const &x) const{
+ if(key_eq()(x,element.first)) return const_iterator(&element);
+ else return &*map.find(x);
+ }
+ size_type count(key_type const &x) const{
+ if(key_eq()(x,element.first)) return 1;
+ else return map.count(x);
+ }
+ std::pair<iterator,iterator> equal_range(key_type const &x){
+ if(key_eq()(x,element.first)) return std::make_pair(iterator(&element),iterator(&element));
+ else{
+ std::pair<typename Map::iterator,typename Map::iterator> ret=map.equal_range(x);
+ return std::make_pair(&*ret.first,&*ret.second);
+ }
+ }
+ std::pair<const_iterator,const_iterator> equal_range(key_type const &x) const{
+ if(key_eq()(x,element.first)) return std::make_pair(iterator(&element),iterator(&element));
+ else{
+ std::pair<typename Map::const_iterator,typename Map::const_iterator> ret=map.equal_range(x);
+ return std::make_pair(&*ret.first,&*ret.second);
+ }
+ }
+
+ key_equal key_eq() const{ return eq::get(); }
+private:
+ Map &map;
+ value_type element;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/optional_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/optional_map.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,91 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_OPTIONAL_MAP_HPP
+#define BOOST_INTRO_DETAIL_OPTIONAL_MAP_HPP
+
+#include <boost/optional/optional.hpp>
+#include <boost/utility/in_place_factory.hpp>
+#include <boost/ref.hpp>
+#include <boost/assert.hpp>
+#include <utility>
+
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Map>
+class optional_map{
+public:
+ typedef typename Map::key_type key_type;
+ typedef typename Map::mapped_type mapped_type;
+ typedef typename Map::value_type value_type;
+ typedef typename Map::reference reference;
+ typedef typename Map::const_reference const_reference;
+ typedef typename Map::iterator iterator;
+ typedef typename Map::const_iterator const_iterator;
+ typedef typename Map::size_type size_type;
+ typedef typename Map::difference_type difference_type;
+ typedef typename Map::pointer pointer;
+ typedef typename Map::const_pointer const_pointer;
+
+ optional_map &operator=(Map const &rhs){
+ this->map=in_place(cref(rhs));
+ return *this;
+ }
+ Map &get(){
+ if(!map) map=in_place();
+ return *map;
+ }
+ iterator begin(){ return map ? map->begin() : empty_map.begin(); }
+ const_iterator begin() const{ return map ? map->begin() : empty_map.begin(); }
+ iterator end(){ return map ? map->end() : empty_map.end(); }
+ const_iterator end() const{ return map ? map->end() : empty_map.end(); }
+ bool empty() const{ return !map || map->empty(); }
+ size_type size() const{ return map ? map->size() : 0; }
+ size_type max_size() const{ return empty_map.max_size(); }
+ mapped_type &operator[](key_type const &x){ return get()[x]; }
+ std::pair<iterator,bool> insert(const_reference x){ return get().insert(x); }
+ iterator insert(iterator pos,const_reference x){ return get().insert(pos,x); }
+ template<class InputIterator>
+ void insert(InputIterator b,InputIterator e){ get().insert(b.e); }
+ void erase(iterator it){
+ BOOST_ASSERT(map);
+ map->erase(it);
+ }
+ size_type erase(key_type const &x){
+ if(map) return map->erase(x); else return 0;
+ }
+ void erase(iterator b,iterator e){
+ if(map) return map->erase(b,e);
+ else BOOST_ASSERT(b == e);
+ }
+ void swap(optional_map &rhs){
+ this->map.swap(rhs.map);
+ }
+ void clear(){ if(map) map->clear(); }
+ iterator find(key_type const &x){ return map ? map->find(x) : empty_map.end(); }
+ const_iterator find(key_type const &x) const{ return map ? map->find(x) : empty_map.end(); }
+ size_type count(key_type const &x) const{ return map ? map->count(x) : 0; }
+ std::pair<iterator,iterator> equal_range(key_type const &x){
+ return map ? map->equal_range(x) : std::make_pair(empty_map.end(),empty_map.end());
+ }
+ std::pair<const_iterator,const_iterator> equal_range(key_type const &x) const{
+ return map ? map->equal_range(x) : std::make_pair(empty_map.end(),empty_map.end());
+ }
+private:
+ optional<Map> map;
+ static Map empty_map;
+};
+
+template<class Map>
+Map optional_map<Map>::empty_map;
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/detail/optional_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/optional_set.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,89 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_OPTIONAL_SET_HPP
+#define BOOST_INTRO_DETAIL_OPTIONAL_SET_HPP
+
+#include <boost/optional/optional.hpp>
+#include <boost/utility/in_place_factory.hpp>
+#include <boost/ref.hpp>
+#include <boost/assert.hpp>
+#include <utility>
+
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Set>
+class optional_set{
+public:
+ typedef typename Set::key_type key_type;
+ typedef typename Set::value_type value_type;
+ typedef typename Set::reference reference;
+ typedef typename Set::const_reference const_reference;
+ typedef typename Set::iterator iterator;
+ typedef typename Set::const_iterator const_iterator;
+ typedef typename Set::size_type size_type;
+ typedef typename Set::difference_type difference_type;
+ typedef typename Set::pointer pointer;
+ typedef typename Set::const_pointer const_pointer;
+
+ optional_set &operator=(Set const &rhs){
+ this->set=in_place(cref(rhs));
+ return *this;
+ }
+ Set &get(){
+ if(!set) set=in_place();
+ return *set;
+ }
+ iterator begin(){ return set ? set->begin() : empty_set.begin(); }
+ const_iterator begin() const{ return set ? set->begin() : empty_set.begin(); }
+ iterator end(){ return set ? set->end() : empty_set.end(); }
+ const_iterator end() const{ return set ? set->end() : empty_set.end(); }
+ bool empty() const{ return !set || set->empty(); }
+ size_type size() const{ return set ? set->size() : 0; }
+ size_type max_size() const{ return empty_set.max_size(); }
+ std::pair<iterator,bool> insert(const_reference x){ return get().insert(x); }
+ iterator insert(iterator pos,const_reference x){ return get().insert(pos,x); }
+ template<class InputIterator>
+ void insert(InputIterator b,InputIterator e){ get().insert(b.e); }
+ void erase(iterator it){
+ BOOST_ASSERT(set);
+ set->erase(it);
+ }
+ size_type erase(const_reference x){
+ if(set) return set->erase(x); else return 0;
+ }
+ void erase(iterator b,iterator e){
+ if(set) return set->erase(b,e);
+ else BOOST_ASSERT(b == e);
+ }
+ void swap(optional_set &rhs){
+ this->set.swap(rhs.set);
+ }
+ void clear(){ if(set) set->clear(); }
+ iterator find(const_reference x){ return set ? set->find(x) : empty_set.end(); }
+ const_iterator find(const_reference x) const{ return set ? set->find(x) : empty_set.end(); }
+ size_type count(const_reference x) const{ return set ? set->count(x) : 0; }
+ std::pair<iterator,iterator> equal_range(const_reference x){
+ return set ? set->equal_range(x) : std::make_pair(empty_set.end(),empty_set.end());
+ }
+ std::pair<const_iterator,const_iterator> equal_range(const_reference x) const{
+ return set ? set->equal_range(x) : std::make_pair(empty_set.end(),empty_set.end());
+ }
+private:
+ optional<Set> set;
+ static Set empty_set;
+};
+
+template<class Set>
+Set optional_set<Set>::empty_set;
+
+}
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/detail/pool.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/pool.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,69 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_POOL_HPP
+#define BOOST_INTRO_DETAIL_POOL_HPP
+
+#include <boost/intro/detail/auto_buffer.hpp>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class T,std::size_t Embed,std::size_t EmbedPools,std::size_t MaxExponent=16>
+class expo_pool{
+public:
+ ~expo_pool(){
+ for(std::size_t c=0;c<pools.size();++c){
+ std::size_t fullsize=capacity(c);
+ vector_view<T> view(
+ pools[c],
+ c == pools.size() - 1 ? back_size : fullsize,
+ capacity(c)
+ );
+ view.clear();
+ ::operator delete(pools[c]);
+ }
+ }
+ T *new_(){
+ return new_(boost::in_place());
+ }
+ template<class InPlaceFactory>
+ T *new_(InPlaceFactory const &factory){
+ if(emb_pool.size() < emb_pool.capacity()){
+ emb_pool.push_back(factory);
+ return &emb_pool.back();
+ }
+ if(pools.empty()
+ || last_pool().size() == last_pool().capacity()){
+ pools.push_back(reinterpret_cast<T *>(
+ ::operator new(sizeof(T)*capacity(pools.size()))
+ ));
+ back_size=0;
+ }
+
+ last_pool().push_back(factory);
+ return &last_pool().back();
+ }
+private:
+ static std::size_t capacity(std::size_t n){
+ if(n > MaxExponent) return Embed << MaxExponent;
+ else return Embed << n;
+ }
+ vector_view<T> last_pool(){
+ return vector_view<T>(pools.back(),back_size,capacity(pools.size() - 1));
+ }
+ static_buffer<T,Embed> emb_pool;
+ typedef auto_buffer<T *,EmbedPools> pools_type;
+ pools_type pools;
+ std::size_t back_size;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/pooled_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/pooled_map.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,74 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_POOLED_MAP_HPP
+#define BOOST_INTRO_DETAIL_POOLED_MAP_HPP
+
+#include <boost/intro/detail/pooled_set.hpp>
+#include <utility>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+
+template<class Key,class Mapped,std::size_t InitialCapacity,class Compare=std::less<Key> >
+class pooled_map{
+public:
+ typedef Key key_type;
+ typedef Mapped mapped_type;
+ typedef std::pair<key_type,mapped_type> value_type;
+ typedef value_type &reference;
+ typedef value_type const &const_reference;
+private:
+ struct comparer{
+ bool operator()(const_reference l,const_reference r) const{
+ return Compare()(l.first,r.first);
+ }
+ bool operator()(const_reference l,key_type const &r) const{
+ return Compare()(l.first,r);
+ }
+ bool operator()(key_type const &l,const_reference r) const{
+ return Compare()(l,r.first);
+ }
+ };
+ typedef pooled_set<
+ value_type,
+ InitialCapacity,
+ comparer
+ > set_type;
+public:
+ typedef typename set_type::size_type size_type;
+ typedef typename set_type::difference_type difference_type;
+ typedef value_type *pointer;
+ typedef value_type const *const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+
+ iterator begin(){ return set.begin(); }
+ const_iterator begin() const{ return set.begin(); }
+ iterator end(){ return set.end(); }
+ const_iterator end() const{ return set.end(); }
+ std::pair<iterator,bool> insert(const_reference x){
+ std::pair<typename set_type::iterator,bool> ret=this->set.insert(x);
+ return std::make_pair(iterator(&*ret.first),ret.second);
+ }
+ size_type size() const{ return set.size(); }
+ iterator find(key_type const &x){
+ return set.find(x,comparer());
+ }
+ const_iterator find(key_type const &x) const{
+ return set.find(x,comparer());
+ }
+private:
+ set_type set;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/pooled_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/pooled_set.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,109 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_POOLED_SET_HPP
+#define BOOST_INTRO_DETAIL_POOLED_SET_HPP
+
+#include <utility>
+#include <boost/intrusive/set.hpp>
+#include <boost/utility/in_place_factory.hpp>
+#include <boost/intro/detail/pool.hpp>
+#include <boost/intro/detail/immutable_iterator.hpp>
+#include <functional>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+
+template<class T,std::size_t InitialCapacity,class Compare=std::less<T> >
+class pooled_set{
+ struct node;
+ typedef intrusive::set_base_hook<
+ intrusive::link_mode<intrusive::normal_link>
+ > hook;
+ typedef intrusive::set<
+ node,
+ intrusive::base_hook<hook>
+ > set_type;
+
+public:
+ typedef T key_type;
+ typedef key_type value_type;
+ typedef value_type &reference;
+ typedef value_type const &const_reference;
+ typedef typename set_type::size_type size_type;
+ typedef typename set_type::difference_type difference_type;
+ typedef value_type *pointer;
+ typedef value_type const *const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+
+ iterator begin(){
+ if(empty()) return end();
+ else return iterator(&*set.begin());
+ }
+ const_iterator begin() const{
+ if(empty()) return end();
+ else return const_iterator(&*set.begin());
+ }
+ iterator end(){ return iterator(0); }
+ const_iterator end() const{ return const_iterator(0); }
+ bool empty() const{ return set.empty(); }
+ std::pair<iterator,bool> insert(const_reference x){
+ typename set_type::insert_commit_data commit_data;
+ std::pair<typename set_type::iterator,bool> ret=
+ this->set.insert_check(x,
+ node::less<Compare>(Compare()),commit_data);
+ if(ret.second){
+ ret.first=this->set.insert_commit(*this->node_pool.new_(in_place(x)),commit_data);
+ return std::make_pair(&ret.first->key,true);
+ }else return std::make_pair(&ret.first->key,false);
+ }
+ size_type size() const{ return set.size(); }
+ template<class Key,class KeyValueCompare>
+ iterator find(Key const &key,KeyValueCompare compare){
+ typename set_type::iterator it=this->set.find(key,node::less<KeyValueCompare>(compare));
+ if(it == this->set.end()) return iterator(0); //TODO use real iterator
+ else return iterator(&it->key);
+ }
+ template<class Key,class KeyValueCompare>
+ const_iterator find(Key const &key,KeyValueCompare compare) const{
+ typename set_type::const_iterator it=this->set.find(key,hash,node::less<KeyValueCompare>(compare));
+ if(it == this->set.end()) return const_iterator(0);
+ else return const_iterator(&it->key);
+ }
+private:
+ struct node : hook{
+ explicit node(const_reference x) : key(x){}
+ bool operator<(node const &o) const{
+ return Compare()(this->key,o.key);
+ }
+ template<class Base>
+ struct less{
+ explicit less(Base const &base) : base(base){}
+ template<class T>
+ bool operator()(T const &o1,node const &o2) const{
+ return base(o1,o2.key);
+ }
+ template<class T>
+ bool operator()(node const &o1,T const &o2) const{
+ return base(o1.key,o2);
+ }
+ private:
+ Base const base;
+ };
+ value_type key;
+ };
+ expo_pool<node,InitialCapacity,2> node_pool;
+ set_type set;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/pooled_unordered_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/pooled_unordered_map.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,83 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_POOLED_UNORDERED_MAP_HPP
+#define BOOST_INTRO_DETAIL_POOLED_UNORDERED_MAP_HPP
+
+#include <boost/intro/detail/pooled_unordered_set.hpp>
+#include <utility>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+
+template<class Key,class Mapped,std::size_t InitialCapacity,class Hash=boost::hash<Key>,class Equal=std::equal_to<Key> >
+class pooled_unordered_map{
+public:
+ typedef Key key_type;
+ typedef Mapped mapped_type;
+ typedef std::pair<key_type,mapped_type> value_type;
+ typedef value_type &reference;
+ typedef value_type const &const_reference;
+private:
+ struct hasher{
+ std::size_t operator()(const_reference x) const{
+ return this->operator()(x.first);
+ }
+ std::size_t operator()(key_type const &x) const{
+ return Hash()(x);
+ }
+ };
+ struct comparer{
+ bool operator()(const_reference l,const_reference r) const{
+ return Equal()(l.first,r.first);
+ }
+ bool operator()(const_reference l,key_type const &r) const{
+ return Equal()(l.first,r);
+ }
+ bool operator()(key_type const &l,const_reference r) const{
+ return Equal()(l,r.first);
+ }
+ };
+ typedef pooled_unordered_set<
+ value_type,
+ InitialCapacity,
+ hasher,
+ comparer
+ > set_type;
+public:
+ typedef typename set_type::size_type size_type;
+ typedef typename set_type::difference_type difference_type;
+ typedef value_type *pointer;
+ typedef value_type const *const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+
+ iterator begin(){ return set.begin(); }
+ const_iterator begin() const{ return set.begin(); }
+ iterator end(){ return set.end(); }
+ const_iterator end() const{ return set.end(); }
+ std::pair<iterator,bool> insert(const_reference x){
+ std::pair<typename set_type::iterator,bool> ret=this->set.insert(x);
+ return std::make_pair(iterator(&*ret.first),ret.second);
+ }
+ size_type size() const{ return set.size(); }
+ iterator find(key_type const &x){
+ return set.find(x,hasher(),comparer());
+ }
+ const_iterator find(key_type const &x) const{
+ return set.find(x,hasher(),comparer());
+ }
+private:
+ set_type set;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/pooled_unordered_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/pooled_unordered_set.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,126 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_POOLED_UNORDERED_SET_HPP
+#define BOOST_INTRO_DETAIL_POOLED_UNORDERED_SET_HPP
+
+#include <utility>
+#include <boost/intrusive/unordered_set.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/utility/in_place_factory.hpp>
+#include <boost/intro/detail/pool.hpp>
+#include <boost/intro/detail/auto_buckets.hpp>
+#include <boost/intro/detail/immutable_iterator.hpp>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+
+template<class T,std::size_t InitialCapacity,class Hash=boost::hash<T>,class Equal=std::equal_to<T> >
+class pooled_unordered_set{
+ struct node;
+ typedef intrusive::unordered_set_base_hook<
+ intrusive::link_mode<intrusive::normal_link>
+ > hook;
+
+ typedef intrusive::unordered_set<
+ node,
+ intrusive::base_hook<hook>,
+ intrusive::power_2_buckets<true>
+ > set_type;
+
+public:
+ pooled_unordered_set()
+ : set(buckets.initial_traits()){}
+
+ typedef T key_type;
+ typedef key_type value_type;
+ typedef value_type &reference;
+ typedef value_type const &const_reference;
+ typedef typename set_type::size_type size_type;
+ typedef typename set_type::difference_type difference_type;
+ typedef value_type *pointer;
+ typedef value_type const *const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+
+ iterator begin(){
+ if(empty()) return end();
+ else return iterator(&*set.begin());
+ }
+ const_iterator begin() const{
+ if(empty()) return end();
+ else return const_iterator(&*set.begin());
+ }
+ iterator end(){ return iterator(0); }
+ const_iterator end() const{ return const_iterator(0); }
+ bool empty() const{ return set.empty(); }
+ std::pair<iterator,bool> insert(const_reference x){
+ typename set_type::insert_commit_data commit_data;
+ std::pair<typename set_type::iterator,bool> ret=
+ this->set.insert_check(x,Hash(),
+ node::equal_to<Equal>(Equal()),commit_data);
+ if(ret.second){
+ ret.first=this->set.insert_commit(*this->node_pool.new_(in_place(x)),commit_data);
+ this->buckets.rehash(this->set);
+ return std::make_pair(&ret.first->key,true);
+ }else return std::make_pair(&ret.first->key,false);
+ }
+ //erased nodes are NOT reused! erase() is only used on
+ //exception at the moment, shortly before the entire map
+ //is destroyed
+ size_type erase(const_reference x){
+ return this->set.erase(x,Hash(),node::equal_to<Equal>(Equal()));
+ }
+ size_type size() const{ return set.size(); }
+ template<class Key,class KeyHasher,class KeyValueEqual>
+ iterator find(Key const &key,KeyHasher hash,KeyValueEqual equal){
+ typename set_type::iterator it=this->set.find(key,hash,node::equal_to<KeyValueEqual>(equal));
+ if(it == this->set.end()) return iterator(0); //TODO use real iterator
+ else return iterator(&it->key);
+ }
+ template<class Key,class KeyHasher,class KeyValueEqual>
+ const_iterator find(Key const &key,KeyHasher hash,KeyValueEqual equal) const{
+ typename set_type::const_iterator it=this->set.find(key,hash,node::equal_to<KeyValueEqual>(equal));
+ if(it == this->set.end()) return const_iterator(0);
+ else return const_iterator(&it->key);
+ }
+private:
+ struct node : hook{
+ explicit node(const_reference x) : key(x){}
+ friend std::size_t hash_value(node const &n){
+ return Hash()(n.key);
+ }
+ bool operator==(node const &o) const{
+ return Equal()(this->key,o.key);
+ }
+ template<class Base>
+ struct equal_to{
+ explicit equal_to(Base const &base) : base(base){}
+ template<class T>
+ bool operator()(T const &o1,node const &o2) const{
+ return base(o1,o2.key);
+ }
+ template<class T>
+ bool operator()(node const &o1,T const &o2) const{
+ return base(o1.key,o2);
+ }
+ private:
+ Base const base;
+ };
+ value_type key;
+ };
+ expo_pool<node,InitialCapacity,2> node_pool;
+ auto_buckets<set_type,InitialCapacity> buckets;
+ set_type set;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/detail/set_insert_view.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/detail/set_insert_view.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,99 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DETAIL_SET_INSERT_VIEW_HPP
+#define BOOST_INTRO_DETAIL_SET_INSERT_VIEW_HPP
+
+#include <boost/intro/detail/immutable_iterator.hpp>
+#include <boost/intro/detail/ebco_container.hpp>
+#include <boost/swap.hpp>
+#include <functional>
+#include <utility>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<class Set,class Equal=std::equal_to<typename Set::key_type> >
+class set_insert_view : public ebco_container<Equal>{
+ typedef ebco_container<Equal> eq;
+public:
+ typedef Equal key_equal;
+ typedef typename Set::key_type key_type;
+ typedef typename Set::value_type value_type;
+ typedef typename Set::reference reference;
+ typedef typename Set::const_reference const_reference;
+ typedef typename Set::pointer pointer;
+ typedef typename Set::const_pointer const_pointer;
+ typedef immutable_iterator<pointer> iterator;
+ typedef immutable_iterator<const_pointer> const_iterator;
+ typedef typename Set::size_type size_type;
+ typedef typename Set::difference_type difference_type;
+
+ set_insert_view(Set &set,const_reference element,key_equal const &eq=key_equal())
+ : eq(eq),set(set),element(element){}
+
+ bool empty() const{ return false; }
+ size_type size() const{ return set.size() + 1; }
+ std::pair<iterator,bool> insert(const_reference x){
+ if(key_eq()(x,element)) return std::make_pair(iterator(&element),false);
+ else{
+ std::pair<typename Set::iterator,bool> ret=set.insert(x);
+ return std::make_pair(&*ret.first,ret.second);
+ }
+ }
+ iterator insert(iterator pos,const_reference x){ return insert(x).first; }
+ template<class InputIterator>
+ void insert(InputIterator b,InputIterator e){
+ for(;b != e;++b) insert(*b);
+ }
+ size_type erase(const_reference x){
+ BOOST_ASSERT(!key_eq()(x,element));
+ return set.erase(x);
+ }
+ void swap(set_insert_view &rhs){
+ set.swap(rhs.set);
+ boost::swap(element,rhs.element);
+ eq::swap(*this);
+ }
+ iterator find(const_reference x){
+ if(key_eq()(x,element)) return iterator(&element);
+ else return &*set.find(x);
+ }
+ const_iterator find(const_reference x) const{
+ if(key_eq()(x,element)) return const_iterator(&element);
+ else return &*set.find(x);
+ }
+ size_type count(const_reference x) const{
+ if(key_eq()(x,element)) return 1;
+ else return set.count(x);
+ }
+ std::pair<iterator,iterator> equal_range(const_reference x){
+ if(key_eq()(x,element)) return std::make_pair(iterator(&element),iterator(&element));
+ else{
+ std::pair<typename Set::iterator,typename Set::iterator> ret=set.equal_range(x);
+ return std::make_pair(&*ret.first,&*ret.second);
+ }
+ }
+ std::pair<const_iterator,const_iterator> equal_range(const_reference x) const{
+ if(key_eq()(x,element)) return std::make_pair(iterator(&element),iterator(&element));
+ else{
+ std::pair<typename Set::const_iterator,typename Set::const_iterator> ret=set.equal_range(x);
+ return std::make_pair(&*ret.first,&*ret.second);
+ }
+ }
+
+ key_equal key_eq() const{ return eq::get(); }
+private:
+ Set &set;
+ value_type element;
+};
+
+}
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/dispatch_polymorphic.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/dispatch_polymorphic.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,143 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_DISPATCH_POLYMORPHIC_HPP
+#define BOOST_INTRO_DISPATCH_POLYMORPHIC_HPP
+
+#include <typeinfo>
+#include <exception>
+#include <boost/serialization/singleton.hpp>
+#include <boost/serialization/smart_cast.hpp>
+#include <boost/intro/detail/flat_map.hpp>
+#include <boost/intro/introspect.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+
+
+namespace boost{
+namespace intro{
+
+struct unregistered_class : std::exception{};
+
+namespace detail{
+
+template<class Algo,class Base,class Derived>
+struct register_class{
+ virtual void instantiate(){
+ reg.instantiate();
+ }
+ struct reg_type{
+ reg_type(){
+ //std::cerr << typeid(Base).name() << " is base of " << typeid(Derived).name() << " for " << typeid(Algo).name() << std::endl << std::endl;
+ this->reg(typename is_const<Base>::type());
+ }
+ void reg(mpl::true_){
+ polymorphic_dispatcher<Algo,Base>::register_derived<Derived const>();
+ }
+ void reg(mpl::false_){
+ polymorphic_dispatcher<Algo,Base>::register_derived<Derived>();
+ }
+ virtual void instantiate(){}
+ };
+ static reg_type reg;
+ typedef void type;
+};
+
+
+template<class Algo,class Base,class Derived>
+typename register_class<Algo,Base,Derived>::reg_type
+register_class<Algo,Base,Derived>::reg;
+
+struct adl_tag{};
+template<class Algo,class Base>
+void register_classes(Algo const *,Base *,int,adl_tag){}
+
+template<class Algo,class Base>
+void register_classes(){
+ using namespace detail;
+ register_classes((Algo *)0,(Base *)0,0,detail::adl_tag());
+}
+
+}
+
+template<class F,class T>
+class polymorphic_dispatcher{
+ typedef typename F::result_type result_type;
+public:
+ static result_type dispatch(F const &f,T &t){
+ return polymorphic_dispatcher::dispatch(f,t,typename is_polymorphic<T>::type());
+ }
+ template<class Derived>
+ static void register_derived(){
+ map_type &map=serialization::singleton<map_type>::get_mutable_instance();
+ dispatcher<Derived> *dispatch=new dispatcher<Derived>();
+ if(!map.insert(std::make_pair(&typeid(Derived),dispatch)).second){
+ delete dispatch;
+ }
+ }
+private:
+ static result_type dispatch(F const &f,T &t,mpl::true_ poly){
+ detail::register_classes<F,T>();
+ map_type const &map=serialization::singleton<map_type>::get_const_instance();
+
+ std::type_info const &type=typeid(t);
+ if(type == typeid(T)) return f(t);
+ else{
+ typename map_type::const_iterator it=map.find(&type);
+ if(it == map.end()) throw unregistered_class();
+ return (*it->second)(f,t);
+ }
+ }
+ static result_type dispatch(F const &f,T &t,mpl::false_ poly){
+ BOOST_ASSERT(typeid(t) == typeid(T));
+ return f(t);
+ }
+
+ struct dispatcher_base{
+ virtual result_type operator()(F const &f,T &t) const = 0;
+ virtual ~dispatcher_base(){}
+ };
+ template<class Derived>
+ struct dispatcher : dispatcher_base{
+ virtual result_type operator()(F const &f,T &t) const{
+ Derived &d=serialization::smart_cast<Derived &,T &>(t);
+ return f(d);
+ }
+ };
+ struct compare{
+ bool operator()(std::type_info const *l,std::type_info const *r) const{
+#pragma warning(push)
+#pragma warning(disable:4800)
+ return l->before(*r);
+#pragma warning(pop)
+ }
+ };
+ struct map_type
+ : intro::detail::flat_map<
+ std::type_info const *,
+ dispatcher_base *,
+ compare
+ >{
+ ~map_type(){
+ for(typename map_type::iterator it=this->begin();it != this->end();++it){
+ delete it->second;
+ }
+ }
+ };
+};
+
+
+
+template<class F,class T>
+typename F::result_type dispatch_polymorphic(F const &f,T &t){
+ return polymorphic_dispatcher<F,T>::dispatch(f,t);
+}
+
+
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/introspect.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/introspect.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,331 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_INTROSPECT_HPP
+#define BOOST_INTRO_INTROSPECT_HPP
+
+#include <boost/intro/reference.hpp>
+#include <boost/intro/semantics.hpp>
+#include <boost/intro/detail/has_complement_operator.hpp>
+#include <boost/intro/detail/ebco_container.hpp>
+#include <boost/intro/detail/complement.hpp>
+#include <boost/type.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/apply_wrap.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/fusion/include/pair.hpp>
+#include <boost/fusion/include/mpl.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/utility/enable_if.hpp>
+
+
+namespace boost{
+namespace intro{
+
+template<class T,std::size_t N>
+class unnamed{};
+
+
+namespace detail{
+
+
+struct null_mapping{
+ template<class Local>
+ null_mapping const &operator()(Local) const{
+ return *this;
+ }
+ template<class Local,class Mapped>
+ null_mapping const &operator()(Local,Mapped const &) const{
+ return *this;
+ }
+ void operator()() const{}
+};
+
+template<class F,class Class,std::size_t UnnamedEnd=0>
+class apply_mapping{
+public:
+ explicit apply_mapping(F const &f) : f(f){}
+ template<class Local>
+ apply_mapping<F,Class,UnnamedEnd+1> const &operator()(Local local) const{
+ this->operator()(local,unnamed<Class,UnnamedEnd>());
+ return reinterpret_cast<apply_mapping<F,Class,UnnamedEnd+1> const &>(*this);
+ }
+ template<class Local,class Mapped>
+ apply_mapping const &operator()(Local local,Mapped const &mapped) const{
+ this->f(local,mapped);
+ return *this;
+ }
+ void operator()() const{}
+private:
+ F const &f;
+};
+
+template<class F,class Class,std::size_t UnnamedEnd=0>
+class apply_break_mapping{
+public:
+ explicit apply_break_mapping(F const &f,std::type_info const *&br) : f(f),br(br){}
+ template<class Local>
+ apply_break_mapping<F,Class,UnnamedEnd+1> const &operator()(Local local) const{
+ this->operator()(local,unnamed<Class,UnnamedEnd>());
+ return reinterpret_cast<apply_break_mapping<F,Class,UnnamedEnd+1> const &>(*this);
+ }
+ template<class Local,class Mapped>
+ apply_break_mapping const &operator()(Local local,Mapped const &mapped) const{
+ if(br){
+ if(*br == typeid(Local)) br=0;
+ else this->f(local,mapped);
+ }
+ return *this;
+ }
+ void operator()() const{}
+private:
+ F const &f;
+ std::type_info const *&br;
+};
+
+template<class F,class Class,class Sequence=mpl::vector0<>,std::size_t UnnamedEnd=0>
+class static_mapping{
+public:
+ explicit static_mapping(F const &f) : f(f){}
+ template<class Local,class Mapped> //TODO stateful mapped
+ static_mapping<
+ F,Class,typename mpl::push_back<Sequence,
+ fusion::pair<Local,Mapped>
+ >::type,UnnamedEnd
+ > const &operator()(Local,Mapped const &) const{
+ return reinterpret_cast<static_mapping<
+ F,Class,typename mpl::push_back<Sequence,
+ fusion::pair<Local,Mapped>
+ >::type,UnnamedEnd> const &>(*this);
+ }
+ template<class Local>
+ static_mapping<
+ F,Class,typename mpl::push_back<Sequence,
+ fusion::pair<Local,unnamed<Class,UnnamedEnd> >
+ >::type,UnnamedEnd+1
+ > const &operator()(Local local) const{
+ this->operator()(local,unnamed<Class,UnnamedEnd>());
+ return reinterpret_cast<static_mapping<
+ F,Class,typename mpl::push_back<Sequence,
+ fusion::pair<Local,unnamed<Class,UnnamedEnd> >
+ >::type,UnnamedEnd+1
+ > const &>(*this);
+ }
+ void operator()() const{
+ this->f(Sequence());
+ }
+private:
+ F const &f;
+};
+
+template<class F,class Sequence=mpl::vector0<> >
+class local_static_mapping{
+public:
+ explicit local_static_mapping(F const &f) : f(f){}
+ template<class Local,class Mapped> //TODO stateful mapped
+ local_static_mapping<F,typename mpl::push_back<Sequence,Local>::type> const &
+ operator()(Local local,Mapped const &) const{
+ return this->operator()(local);
+ }
+ template<class Local>
+ local_static_mapping<F,typename mpl::push_back<Sequence,Local>::type> const &
+ operator()(Local) const{
+ return reinterpret_cast<
+ local_static_mapping<F,typename mpl::push_back<Sequence,Local>::type> const &
+ >(*this);
+ }
+ void operator()() const{
+ this->f(Sequence());
+ }
+private:
+ F const &f;
+};
+
+}
+
+template<class T,class F>
+void apply_sequence(F const &f){
+ introspect(
+ detail::static_mapping<F,T>(f),
+ type<typename remove_const<T>::type>()
+ );
+}
+
+namespace detail{
+
+template<class T,class F>
+void for_each(F const &f,mpl::false_ complement){
+ introspect( //ADL
+ detail::apply_mapping<F,T>(f),
+ type<typename remove_const<T>::type>()
+ );
+}
+
+template<class T,class F>
+apply_break_mapping<F,T> get_undo_mapping(F const &f,std::type_info const *&last_local){
+ return apply_break_mapping<F,T>(f,last_local);
+}
+
+template<class F,class T>
+struct apply_catcher{
+ explicit apply_catcher(F const &f,std::type_info const *last_local)
+ : f(f),last_local(last_local){}
+ template<class Local,class Mapped>
+ void operator()(Local local,Mapped const &mapped) const{
+ //the type of Local is saved for the case f(p) throws an exception.
+ //this creates much better code than using a try-block, and
+ //it creates a lot less introspect() instantiations than
+ //undo-ing with a static Local in a catch-block.
+ //cost: type_info::operator== on exception for each member.
+ last_local=&typeid(Local);
+ f(local,mapped);
+ }
+private:
+ F const &f;
+ std::type_info const *&last_local;
+};
+
+template<class T,class F>
+void for_each(F const &f,mpl::true_ complement){
+ std::type_info const *last_local=0;
+ try{
+ introspect( //ADL
+ apply_mapping<apply_catcher<F,T> >(apply_catcher<F,T>(f,last_local)),
+ type<typename remove_const<T>::type>()
+ );
+ }catch(...){
+ BOOST_ASSERT(last_local);
+ introspect(
+ get_undo_mapping<T>(~f,last_local),
+ type<typename remove_const<T>::type>());
+ throw;
+ }
+}
+
+template<class F>
+struct mapped_discarder{
+ explicit mapped_discarder(F const &f) : f(f){}
+ template<class Local,class Mapped>
+ void operator()(Local local,Mapped const &) const{
+ f(local);
+ }
+ mapped_discarder<complement<F> > operator~() const{
+ return mapped_discarder<complement<F> >(complement<F>(f));
+ }
+private:
+ F const f;
+};
+
+template<class F>
+struct has_complement_operator<mapped_discarder<F> >
+ : has_complement_operator<F>{};
+
+}
+
+template<class T,class F>
+void for_each(F const &f){
+ detail::for_each<T>(f,typename detail::has_complement_operator<F>::type());
+}
+
+template<class T,class F>
+void for_each_local(F const &f){
+ for_each<T>(detail::mapped_discarder<F>(f));
+}
+
+
+template<class T,class F>
+void apply_local_sequence(F const &f){
+ introspect(
+ detail::local_static_mapping<F>(f),
+ type<typename remove_const<T>::type>()
+ );
+}
+
+
+template<class Class,class T,T Class::*Ptr,class Semantics>
+class member_t{};
+
+namespace detail{
+
+template<class Semantics,class Add>
+struct add_semantics{
+ typedef semantics<
+ typename mpl::fold<
+ typename Add::set,
+ typename Semantics::set,
+ mpl::apply_wrap1<mpl::_2,mpl::_1>
+ >::type,
+ typename add_semantics<
+ typename Semantics::indir_semantics,
+ typename Add::indir_semantics
+ >::type
+ > type;
+};
+
+template<class Semantics>
+struct add_semantics<Semantics,semantics<> >{
+ typedef Semantics type;
+};
+
+template<class Arg>
+struct get_semantics{
+ typedef typename mpl::if_<
+ is_semantics<Arg>,
+ Arg,
+ semantics<Arg>
+ >::type type;
+};
+
+}
+
+template<class Class,class T,T Class::*Ptr>
+member_t<
+ Class,
+ T,
+ Ptr,
+ typename default_semantics<T>::type
+> member(){
+ return member_t<
+ Class,
+ T,
+ Ptr,
+ typename default_semantics<T>::type
+ >();
+}
+
+template<class Class,class T,T Class::*Ptr,class Semantics>
+member_t<
+ Class,
+ T,
+ Ptr,
+ typename detail::add_semantics<
+ typename default_semantics<T>::type,
+ typename detail::get_semantics<Semantics>::type
+ >::type
+> member(){
+ return member_t<
+ Class,
+ T,
+ Ptr,
+ typename detail::add_semantics<
+ typename default_semantics<T>::type,
+ typename detail::get_semantics<Semantics>::type
+ >::type
+ >();
+}
+template<class Base>
+class base_class{};
+
+template<unsigned int Version>
+class version{};
+
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/memory_archive.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/memory_archive.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,47 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_MEMORY_ARCHIVE_HPP
+#define BOOST_INTRO_MEMORY_ARCHIVE_HPP
+
+#include <boost/intro/detail/auto_buffer.hpp>
+#include <boost/intro/char_archive.hpp>
+#include <boost/intro/array_extension.hpp>
+#include <utility>
+
+namespace boost{
+namespace intro{
+
+namespace detail{
+
+class memory_oarchive_base{
+protected:
+ typedef detail::auto_buffer<char,256> buffer_type;
+ buffer_type buffer;
+};
+
+}
+
+class memory_oarchive
+ : public detail::memory_oarchive_base
+ , public char_oarchive<vector_back_insert_iterator<detail::memory_oarchive_base::buffer_type> >{
+ typedef vector_back_insert_iterator<buffer_type> iterator_type;
+ typedef char_oarchive<iterator_type> archive_type;
+public:
+ memory_oarchive()
+ : archive_type(iterator_type(buffer)){}
+ void reserve(std::size_t n){
+ buffer.reserve(n);
+ }
+ std::pair<char const *,char const *> data() const{
+ return std::make_pair(buffer.begin(),buffer.end());
+ }
+};
+
+
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/move.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/move.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,153 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_MOVE_HPP
+#define BOOST_INTRO_MOVE_HPP
+
+#include <boost/intro/apply_binary.hpp>
+#include <boost/intro/reset_shared.hpp>
+#include <boost/intro/detail/map_insert_view.hpp>
+#include <boost/intro/detail/pooled_unordered_map.hpp>
+#include <boost/intro/detail/optional_map.hpp>
+#include <boost/intro/detail/ebco_container.hpp>
+#include <boost/mpl/has_key.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_class.hpp>
+#include <boost/assert.hpp>
+
+namespace boost{
+namespace intro{
+
+template<class Map>
+class move_data{
+public:
+ explicit move_data(Map &map) : map(map){}
+ template<class T>
+ void register_object(T *src,T *dest){
+ BOOST_VERIFY( map.insert(std::make_pair(src,dest)).second );
+ }
+private:
+ Map &map;
+};
+
+namespace detail{
+
+class null_move_data{
+public:
+ template<class T>
+ void register_object(T *,T *){}
+};
+
+template<class Data>
+class mover{
+ struct undo{
+ undo() : mover_(data){}
+ template<class T,class Semantics>
+ void operator()(T &src,T &dest,Semantics) const{
+ mover_(dest,src,Semantics());
+ }
+ private:
+ null_move_data data;
+ mover<null_move_data> mover_;
+ };
+public:
+ explicit mover(Data &data) : data(data){}
+ template<class T,class Semantics>
+ void operator()(T &src,T &dest,Semantics) const{
+ BOOST_ASSERT((!mpl::has_key<typename Semantics::set,polymorphic>::type::value));
+ this->insert_shared(src,dest,typename mpl::has_key<typename Semantics::set,shared>::type());
+ this->operator()(src,dest,Semantics(),typename is_class<T>::type());
+ }
+ template<class T,class Semantics>
+ void operator()(reference<T> &src,reference<T> &dest,Semantics) const{
+ this->insert_shared(src,dest,typename mpl::has_key<typename Semantics::set,shared>::type());
+ new (&dest) reference<T>(src.get());
+ src.~reference();
+ }
+ undo operator ~() const{ return undo(); }
+private:
+ template<class T>
+ void insert_shared(T &src,T &dest,mpl::true_ shared) const{
+ data.register_object(&src,&dest);
+ }
+ template<class T>
+ void insert_shared(T &src,T &dest,mpl::false_ shared) const{}
+ template<class T,class Semantics>
+ void operator()(T &src,T &dest,Semantics,mpl::true_ iscl) const{
+ using intro::move;
+ move(data,src,dest,Semantics());
+ }
+ template<class T,class Semantics>
+ void operator()(T &src,T &dest,Semantics,mpl::false_ iscl) const{
+ dest=src;
+ src=T();
+ }
+ Data &data;
+};
+
+template<class T,class Semantics>
+void move(T &src,T &dest,Semantics,mpl::true_ shared){
+ typedef detail::optional_map<detail::pooled_unordered_map<void *,void *,4> > omap_type;
+ omap_type omap;
+ move_data<omap_type> data(omap);
+ using intro::move;
+ move(data,src,dest);
+ try{
+ typedef detail::map_insert_view<oset_type> map_type;
+ map_type map(omap,std::make_pair(&src,&dest));
+ reset_shared_data<map_type> resdata(map);
+ reset_shared(resdata,dest);
+ }catch(...){
+ null_move_data ndata;
+ move(ndata,dest,src);
+ throw;
+ }
+}
+
+template<class T,class Semantics>
+void move(T &src,T &dest,Semantics,mpl::false_ shared){
+ typedef detail::optional_map<detail::pooled_unordered_map<void *,void *,4> > map_type;
+ map_type map;
+ move_data<map_type> data(map);
+ using intro::move;
+ move(data,src,dest,Semantics());
+ try{
+ reset_shared_data<map_type> resdata(map);
+ reset_shared(resdata,dest);
+ }catch(...){
+ null_move_data ndata;
+ move(ndata,dest,src);
+ throw;
+ }
+}
+
+}
+
+template<class Data,class T,class Semantics>
+void move(Data &data,T &src,T &dest,Semantics){
+ apply_binary(detail::mover<Data>(data),src,dest);
+}
+
+template<class Data,class T>
+void move(Data &data,T &src,T &dest){
+ move(data,src,dest,typename default_semantics<T>::type());
+}
+
+template<class T,class Semantics>
+void move(T &src,T &dest,Semantics){
+ detail::move(src,dest,Semantics(),typename mpl::has_key<typename Semantics::set,shared>::type());
+}
+
+
+template<class T>
+void move(T &src,T &dest){
+ move(src,dest,typename default_semantics<T>::type());
+}
+
+
+}
+}
+
+#endif

Added: sandbox/intro/boost/intro/print.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/print.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,136 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_PRINT_HPP
+#define BOOST_INTRO_PRINT_HPP
+
+#include <boost/intro/introspect.hpp>
+#include <boost/intro/detail/indent_streambuf.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/type_traits/is_arithmetic.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/lexical_cast.hpp>
+#include <ostream>
+#include <streambuf>
+#include <string>
+#include <cstring>
+
+namespace boost{
+namespace intro{
+namespace detail{
+
+template<std::size_t N>
+class unnamed_name{
+public:
+ static char const *get(){
+ return string.c_str();
+ }
+private:
+ static std::string string;
+};
+
+template<std::size_t N>
+std::string unnamed_name<N>::string(std::string("unnamed")+lexical_cast<std::string>(N));
+
+template<class T,class Transformation>
+void print(T const &t,std::ostream &out,Transformation const &,mpl::true_ ptrorint){
+ out << t;
+}
+
+template<class T,class Transformation>
+void print(T const &t,std::ostream &out,Transformation const &transform,mpl::false_ ptrorint){
+ out << '{' << std::endl;
+ indent_streambuf indent(*out.rdbuf(),true);
+ std::ostream indent_out(&indent);
+ intro::for_each<T>(detail::printer<T,Transformation>(t,indent_out,transform));
+ out << '}';
+}
+
+
+template<class T,class Transformation>
+void print(reference<T> const &t,std::ostream &out,Transformation const &transform){
+ print(&t.get(),out,transform);
+}
+
+template<class T>
+char const *typeid_name(){
+ char const *name=typeid(T).name();
+#ifdef BOOST_MSVC
+ while(char const *scope=std::strstr(name,"::")){
+ char const *templ=std::strchr(name,'<');
+ if(templ && templ < scope) break;
+ name=scope+2;
+ }
+ if(strncmp(name,"class ",6) == 0) name+=6;
+ else if(strncmp(name,"struct ",7) == 0) name+=7;
+#endif
+ return name;
+}
+
+template<class Class,class Transformation>
+class printer{
+public:
+ explicit printer(Class const &c,std::ostream &out,Transformation const &transform)
+ : c(c),out(out),transform(transform){}
+ template<class T,T Class::*Ptr,class Semantics,class Mapped>
+ void operator()(member_t<Class,T,Ptr,Semantics>,Mapped const &mapped) const{
+ out << typeid_name<T>() << ' ' << transform(mapped) << " = ";
+ print(c.*Ptr,out,transform);
+ out << ';' << std::endl;
+ }
+ template<class T,reference<T> Class::*Ptr,class Semantics,class Mapped>
+ void operator()(member_t<Class,reference<T>,Ptr,Semantics>,Mapped const &mapped) const{
+ out << typeid_name<T>() << " & " << transform(mapped) << " = ";
+ print(c.*Ptr,out,transform);
+ out << ';' << std::endl;
+ }
+ template<class Base,class Mapped>
+ void operator()(base_class<Base>,Mapped const &) const{
+ out << typeid_name<Base>() << " = ";
+ Base const &base=c;
+ print(base,out,transform);
+ out << ';' << std::endl;
+ }
+private:
+ Class const &c;
+ std::ostream &out;
+ Transformation transform;
+};
+
+
+
+}
+
+template<class T,class Transformation>
+void print(T const &t,std::ostream &out,Transformation const &transform){
+ detail::print(t,out,transform,mpl::bool_<is_pointer<T>::type::value || is_arithmetic<T>::type::value>());
+}
+
+class print_transformation{
+public:
+ char const *operator()(char *m) const{ return m; }
+ char const *operator()(char const *m) const{ return m; }
+ char const *operator()(std::string const &s) const{ return s.c_str(); }
+ template<class Class,std::size_t N>
+ std::string operator()(unnamed<Class,N>) const{
+ return detail::unnamed_name<N>::get();
+ }
+ template<class Mapped>
+ char const *operator()(Mapped const &) const{
+ return detail::typeid_name<Mapped>();
+ }
+};
+
+
+template<class T>
+void print(T const &t,std::ostream &out){
+ print(t,out,print_transformation());
+}
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/reference.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/reference.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,64 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_REFERENCE_HPP
+#define BOOST_INTRO_REFERENCE_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/assert.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/type_traits/is_class.hpp>
+
+namespace boost{
+namespace intro{
+
+template<class T>
+class reference : noncopyable{
+ void true_type(){}
+ typedef void (reference::*unspecified_bool_type)();
+public:
+ reference(T &t) : t(&t){}
+ operator T &() const{ return *t; }
+ T &get() const{ return *t; }
+ T *get_pointer() const{ return t; }
+ T *operator->() const{ return t; }
+ ~reference(){ t=0; }
+private:
+ T *t;
+};
+
+template<class T>
+struct is_reference_wrapper : mpl::false_{};
+template<class T>
+struct is_reference_wrapper<reference<T> > : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> const> : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> volatile> : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> const volatile> : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> const &> : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> volatile &> : mpl::true_{};
+template<class T>
+struct is_reference_wrapper<reference<T> const volatile &> : mpl::true_{};
+
+template<class T>
+struct is_class :
+ mpl::and_<
+ boost::is_class<T>,
+ mpl::not_<is_reference_wrapper<T> >
+ >{};
+
+
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/register_class.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/register_class.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,26 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_REGISTER_CLASS_HPP
+#define BOOST_INTRO_REGISTER_CLASS_HPP
+
+#include <boost/intro/dispatch_polymorphic.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
+
+#define BOOST_INTRO_REGISTER_CLASS(Derived) \
+ template<class Algo,class Base> \
+ typename boost::mpl::eval_if_c< \
+ !boost::is_same<Base,Derived>::value && boost::is_base_of<Base,Derived>::value, \
+ boost::intro::detail::register_class<Algo,Base,Derived>, \
+ boost::mpl::identity<void> \
+ >::type \
+ register_classes(Algo const *,Base *,Derived *,boost::intro::detail::adl_tag){}
+
+
+#endif

Added: sandbox/intro/boost/intro/reset_shared.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/reset_shared.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,103 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_RESET_SHARED_HPP
+#define BOOST_INTRO_RESET_SHARED_HPP
+
+#include <boost/intro/apply_recursive.hpp>
+#include <boost/intro/dispatch_polymorphic.hpp>
+#include <boost/bind.hpp>
+
+namespace boost{
+namespace intro{
+
+template<class Map>
+class reset_shared_data{
+public:
+ explicit reset_shared_data(Map const &map) : map(map){}
+ template<class T>
+ T *translate(T *t) const{
+ typename Map::const_iterator it=map.find(t);
+ std::cerr << "translation for " << t << ": ";
+ if(it == map.end()) std::cerr << "not found\n";
+ else std::cerr << it->second << std::endl;
+ if(it == map.end()) return t;
+ else return static_cast<T *>(it->second);
+ }
+private:
+ Map const &map;
+};
+
+namespace detail{
+
+template<class Data>
+struct shared_resetter{
+ explicit shared_resetter(Data const &data) : data(data){}
+ template<class T,class Semantics>
+ void operator()(T &t,Semantics) const{}
+ template<class T,class Semantics>
+ void operator()(T *&t,Semantics) const{
+ if(t) t=&this->get(*t,Semantics());
+ }
+ template<class T,class Semantics>
+ void operator()(T * const &t,Semantics) const{
+ if(t) const_cast<T *&>(t)=&this->get(*t,Semantics());
+ }
+ template<class T,class Semantics>
+ void operator()(reference<T> &t,Semantics) const{
+ T &tmp=this->get(t.get(),Semantics());
+ t.~reference();
+ new (&t) reference<T>(tmp);
+ }
+ template<class T,class Semantics>
+ void operator()(reference<T> const &t,Semantics) const{
+ T &tmp=this->get(t.get(),Semantics());
+ t.~reference();
+ new (&t) reference<T>(tmp);
+ }
+ //TODO operator~
+private:
+ template<class T,class Semantics>
+ T &get(T &t,Semantics) const{
+ return this->get(t,typename mpl::has_key<typename Semantics::indir_semantics::set,polymorphic>::type(),
+ typename mpl::has_key<typename Semantics::indir_semantics::set,shared>::type());
+ }
+ template<class T>
+ T &get(T &t,mpl::false_ poly,mpl::true_ shared) const{
+ return *data.translate(&t);
+ }
+ template<class T>
+ struct getter{
+ typedef T &result_type;
+ template<class Derived>
+ T &operator()(shared_resetter const &that,Derived &dt) const{
+ return that.get(dt,mpl::false_(),mpl::true_());
+ }
+ };
+ template<class T>
+ T &get(T &t,mpl::true_ poly,mpl::true_ shared) const{
+ //TODO optimization: the same object is dispatched shortly
+ //thereafter by apply_recursive
+ return dispatch_polymorphic(bind(getter<T>(),cref(*this),_1),t);
+ }
+ template<class T,bool Poly>
+ T &get(T &t,mpl::bool_<Poly>,mpl::false_ shared) const{
+ return t;
+ }
+ Data const &data;
+};
+
+}
+
+template<class Data,class T>
+void reset_shared(Data const &data,T &t){
+ apply_recursive(detail::shared_resetter<Data>(data),t);
+}
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/semantics.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/semantics.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,98 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_SEMANTICS_HPP
+#define BOOST_INTRO_SEMANTICS_HPP
+
+#include <boost/mpl/set.hpp>
+#include <boost/mpl/is_sequence.hpp>
+#include <boost/mpl/insert.hpp>
+#include <boost/mpl/erase_key.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
+
+
+namespace boost{
+namespace intro{
+
+namespace detail{
+struct semantics_base{};
+}
+
+template<class Semantics=mpl::set0<>,class IndirSemantics=mpl::na>
+struct semantics : detail::semantics_base{
+ typedef typename mpl::if_<
+ mpl::is_sequence<Semantics>,
+ Semantics,
+ mpl::set1<Semantics>
+ >::type set;
+ typedef typename mpl::if_<
+ is_same<IndirSemantics,mpl::na>,
+ semantics<>,
+ IndirSemantics
+ >::type indir_semantics;
+};
+
+struct shared{
+ template<class Set>
+ struct apply : mpl::insert<Set,shared>{};
+};
+struct unique{
+ template<class Set>
+ struct apply : mpl::erase_key<Set,shared>{};
+};
+struct polymorphic{
+ template<class Set>
+ struct apply : mpl::insert<Set,polymorphic>{};
+};
+struct sealed{
+ template<class Set>
+ struct apply : mpl::erase_key<Set,polymorphic>{};
+};
+
+
+template<class T>
+struct is_semantics
+ : is_base_of<detail::semantics_base,T>{};
+
+template<class T>
+struct default_semantics{
+ typedef semantics<> type;
+};
+
+template<class T>
+class default_semantics<T *>{
+ typedef typename default_semantics<T>::type deref_semantics;
+ typedef typename shared::template apply<typename deref_semantics::set>::type shared_added;
+ typedef typename mpl::if_<
+ is_polymorphic<T>,
+ typename polymorphic::template apply<shared_added>::type,
+ shared_added
+ >::type added;
+public:
+ typedef semantics<
+ mpl::set0<>,
+ semantics<
+ added,
+ typename deref_semantics::indir_semantics
+ >
+ > type;
+};
+
+template<class T>
+struct default_semantics<reference<T> >{
+ typedef typename default_semantics<T *>::type type;
+};
+
+typedef semantics<> shared_pointer;
+typedef shared_pointer shared_reference;
+typedef semantics<mpl::set0<>,semantics<unique> > unique_pointer;
+typedef unique_pointer unique_reference;
+
+}
+}
+#endif

Added: sandbox/intro/boost/intro/serialize.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/serialize.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,183 @@
+#ifndef BOOST_INTRO_SERIALIZE_HPP
+#define BOOST_INTRO_SERIALIZE_HPP
+
+#include <boost/intro/apply.hpp>
+#include <boost/intro/dispatch_polymorphic.hpp>
+#include <boost/intro/detail/pooled_unordered_map.hpp>
+#include <boost/intro/detail/optional_map.hpp>
+#include <boost/intro/detail/map_insert_view.hpp>
+#include <boost/intro/detail/pooled_map.hpp>
+#include <cstring>
+
+namespace boost{
+namespace intro{
+
+template<class ObjectMap,class TypeMap>
+class serialize_data{
+public:
+ serialize_data(ObjectMap &omap,TypeMap &tmap) : omap(omap),tmap(tmap){}
+ template<class T>
+ std::pair<unsigned int,bool> register_object(T const &t){
+ std::pair<typename ObjectMap::iterator,bool> ret=
+ omap.insert(std::make_pair(&t,omap.size()));
+ return std::make_pair(ret.first->second,ret.second);
+ }
+ template<class T>
+ std::pair<unsigned int,bool> register_type(){
+ std::pair<typename TypeMap::iterator,bool> ret=
+ tmap.insert(std::make_pair(&typeid(T),tmap.size()));
+ return std::make_pair(ret.first->second,ret.second);
+ }
+private:
+ ObjectMap &omap;
+ TypeMap &tmap;
+};
+
+
+template<class Archive,class Data,class T,class Semantics>
+void serialize_member(Archive &ar,Data &data,T const &t,Semantics){
+ detail::serialize_member(ar,data,t,Semantics(),
+ typename mpl::has_key<typename Semantics::set,polymorphic>::type(),
+ typename mpl::has_key<typename Semantics::set,shared>::type());
+}
+
+namespace detail{
+
+template<class Archive,class Data,class T,class Semantics,bool Shared>
+void serialize_member(Archive &ar,Data &data,T const &t,Semantics,mpl::true_ poly,mpl::bool_<Shared>){
+ dispatch_polymorphic(
+ bind(
+ detail::member_serializer<Archive,Data>(ar,data),
+ _1,
+ Semantics(),
+ mpl::false_(),
+ mpl::bool_<Shared>()
+ ),t);
+}
+template<class Archive,class Data,class T,class Semantics>
+void serialize_member(Archive &ar,Data &data,T const &t,Semantics,mpl::false_ poly,mpl::true_ shared_){
+ std::pair<unsigned int,bool> ret=data.register_object(t);
+ ar << ret.first;
+ if(ret.second){
+ detail::serialize_member(ar,data,t,Semantics(),poly,mpl::false_());
+ }
+}
+template<class Archive,class Data,class T,class Semantics>
+void serialize_member(Archive &ar,Data &data,T const &t,Semantics,mpl::false_ poly,mpl::false_ shared_){
+ serialize(ar,data,t,Semantics());
+}
+
+
+template<class Archive,class Data>
+struct member_serializer{
+ typedef void result_type;
+ member_serializer(Archive &ar,Data &data)
+ : ar(ar),data(data){}
+ template<class T,class Semantics>
+ void operator()(T const &t,Semantics) const{
+ intro::serialize_member(ar,data,t,Semantics());
+ }
+ template<class T,class Semantics,bool Shared>
+ void operator()(T const &t,Semantics,mpl::false_ poly,mpl::bool_<Shared> sha) const{
+ //called by polymorphic dispatch
+ std::pair<unsigned int,bool> ret=data.register_type<T>();
+ ar << ret.first;
+ if(ret.second){
+ char const *name=typeid(T).name();
+ std::size_t const length=std::strlen(name);
+ ar << length;
+ ar.save_binary(name,length);
+ }
+ detail::serialize_member(ar,data,t,Semantics(),poly,sha);
+ }
+private:
+ Archive &ar;
+ Data &data;
+};
+
+template<class Archive,class Data,class T>
+void serialize_class(Archive &ar,Data &data,T const &t,mpl::true_ is_class_){
+ using intro::apply;
+ apply(detail::member_serializer<Archive,Data>(ar,data),t);
+}
+
+template<class Archive,class Data,class T>
+void serialize_class(Archive &ar,Data &data,T const &t,mpl::false_ is_class_){
+ ar << t;
+}
+
+
+template<class Archive,class Data,class T,class Semantics>
+void serialize(Archive &ar,Data &data,T * const &t,Semantics){
+ //TODO optimization: if the pointer is shared, whether it is set or not
+ //could be encoded in the object id
+ if(t){
+ ar << true;
+ intro::serialize_member(ar,data,*t,typename Semantics::indir_semantics());
+ }else ar << false;
+}
+
+template<class Archive,class Data,class T,class Semantics>
+void serialize(Archive &ar,Data &data,reference<T> const &t,Semantics){
+ intro::serialize_member(ar,data,t.get(),typename Semantics::indir_semantics());
+}
+
+struct type_info_less{
+ bool operator()(std::type_info const *t1,std::type_info const *t2) const{
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4800)
+#endif
+ return t1->before(*t2);
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+ }
+};
+
+template<class Archive,class T,class Semantics>
+void serialize(Archive &ar,T const &t,Semantics,mpl::false_ shared){
+ typedef detail::optional_map<detail::pooled_unordered_map<void const *,unsigned int,4> > omap_type;
+ typedef detail::optional_map<detail::pooled_map<std::type_info const *,unsigned int,1,type_info_less> > tmap_type;
+ omap_type omap; tmap_type tmap;
+ serialize_data<omap_type,tmap_type> data(omap,tmap);
+ using intro::serialize;
+ serialize(ar,data,t,Semantics());
+}
+
+template<class Archive,class T,class Semantics>
+void serialize(Archive &ar,T const &t,Semantics,mpl::true_ shared){
+ typedef detail::optional_map<detail::pooled_unordered_map<void const *,unsigned int,4> > omap_type;
+ typedef detail::optional_map<detail::pooled_map<std::type_info const *,unsigned int,1,type_info_less> > tmap_type;
+ omap_type omap; tmap_type tmap;
+ typedef detail::map_insert_view<omap_type> omap_view_type;
+ omap_view_type omap_view(omap,std::make_pair(&t,0));
+ serialize_data<omap_view_type,tmap_type> data(omap_view,tmap);
+
+ using intro::serialize;
+ serialize(ar,data,t,Semantics());
+}
+
+}
+
+template<class Archive,class Data,class T,class Semantics>
+void serialize(Archive &ar,Data &data,T const &t,Semantics){
+ detail::serialize_class(ar,data,t,typename is_class<T>::type());
+}
+
+
+template<class Archive,class T,class Semantics>
+void serialize(Archive &ar,T const &t,Semantics){
+ detail::serialize(ar,t,Semantics(),typename mpl::has_key<typename Semantics::set,shared>::type());
+}
+
+template<class Archive,class T>
+void serialize(Archive &ar,T const &t){
+ serialize(ar,t,typename default_semantics<T>::type());
+}
+
+}
+}
+
+
+#endif

Added: sandbox/intro/boost/intro/vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/intro/boost/intro/vector.hpp 2010-06-27 06:51:46 EDT (Sun, 27 Jun 2010)
@@ -0,0 +1,48 @@
+// Copyright Stefan Strasser 2010.
+// 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)
+
+#ifndef BOOST_INTRO_VECTOR_HPP
+#define BOOST_INTRO_VECTOR_HPP
+
+#include <vector>
+#include <boost/intro/container.hpp>
+
+namespace boost{
+namespace intro{
+
+template<class F,class Data,class T,class Allocator,class Semantics>
+void apply_recursive(F const &f,Data &data,std::vector<T,Allocator> &v,Semantics){
+ intro::container_apply_recursive(f,data,v,Semantics());
+}
+template<class F,class Data,class T,class Allocator,class Semantics>
+void apply_recursive(F const &f,Data &data,std::vector<T,Allocator> const &v,Semantics){
+ intro::container_apply_recursive(f,data,v,Semantics());
+}
+
+template<class Archive,class Data,class T,class Allocator,class Semantics>
+void serialize(Archive &ar,Data &data,std::vector<T,Allocator> const &v,Semantics){
+ intro::container_serialize(ar,data,v,Semantics());
+}
+
+template<class Map,class T,class Allocator,class Semantics>
+void move(Map &map,std::vector<T,Allocator> &src,std::vector<T,Allocator> &dest,Semantics){
+ intro::container_move(map,src,dest,Semantics());
+}
+
+template<class T,class Allocator>
+void copy_shallow(std::vector<T,Allocator> const &src,std::vector<T,Allocator> &dest){
+ intro::container_copy_shallow(src,dest);
+}
+
+template<class T,class Allocator,class Transformation>
+void print(std::vector<T,Allocator> const &t,std::ostream &out,Transformation const &transform){
+ intro::container_print(t,out,transform);
+}
+
+}
+}
+
+
+#endif


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