From 25f29a22871d551801f94e538b468cc5c42a544f Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 4 Sep 2013 06:24:54 -0700 Subject: [PATCH] Add new-styled Intrusive and MPL modules --- Builds/VisualStudio2012/beast.vcxproj | 10 + Builds/VisualStudio2012/beast.vcxproj.filters | 39 ++ beast/intrusive/ForwardList.h | 445 ++++++++++++++++++ beast/intrusive/PointerTraits.h | 87 ++++ beast/mpl.h | 31 ++ beast/mpl/AddConst.h | 38 ++ beast/mpl/IfConst.h | 46 ++ beast/mpl/PointerToOther.h | 68 +++ beast/mpl/RemoveConst.h | 46 ++ beast/mpl/RemoveConstVolatile.h | 43 ++ beast/mpl/RemoveReference.h | 46 ++ beast/mpl/RemoveVolatile.h | 46 ++ modules/beast_core/beast_core.h | 9 +- 13 files changed, 952 insertions(+), 2 deletions(-) create mode 100644 beast/intrusive/ForwardList.h create mode 100644 beast/intrusive/PointerTraits.h create mode 100644 beast/mpl.h create mode 100644 beast/mpl/AddConst.h create mode 100644 beast/mpl/IfConst.h create mode 100644 beast/mpl/PointerToOther.h create mode 100644 beast/mpl/RemoveConst.h create mode 100644 beast/mpl/RemoveConstVolatile.h create mode 100644 beast/mpl/RemoveReference.h create mode 100644 beast/mpl/RemoveVolatile.h diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj index 98652f38e9..c047fa6711 100644 --- a/Builds/VisualStudio2012/beast.vcxproj +++ b/Builds/VisualStudio2012/beast.vcxproj @@ -69,6 +69,16 @@ + + + + + + + + + + diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters index 00d3da7132..5973783fcd 100644 --- a/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Builds/VisualStudio2012/beast.vcxproj.filters @@ -164,6 +164,15 @@ {08ec13ba-4058-4ad7-afbb-cbb1c6e2fc4a} + + {92d1bb42-289a-4444-85c7-cb87540f2fff} + + + {8832eb52-53f9-4850-8dc9-1d579a386a0e} + + + {5904368f-a0f2-4d26-a031-8cbe4448dc3f} + @@ -941,6 +950,36 @@ beast_core\text + + beast\intrusive + + + beast\intrusive + + + beast\mpl + + + beast\mpl + + + beast\mpl + + + beast\mpl + + + beast\mpl + + + beast\mpl + + + beast + + + beast\mpl + diff --git a/beast/intrusive/ForwardList.h b/beast/intrusive/ForwardList.h new file mode 100644 index 0000000000..1cf6b069df --- /dev/null +++ b/beast/intrusive/ForwardList.h @@ -0,0 +1,445 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED +#define BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED + +#include + +#include "PointerTraits.h" +#include "../mpl.h" + +// Ideas based on boost + +namespace beast { +namespace intrusive { + +//------------------------------------------------------------------------------ + +namespace detail { + +// Holds the size field +struct SizeHolder +{ +public: + typedef std::size_t size_type; + + inline size_type size () const noexcept + { + return m_size; + } + + inline void set (size_type new_size) noexcept + { + m_size = new_size; + } + + inline void increment () noexcept + { + ++m_size; + } + + inline void decrement () noexcept + { + --m_size; + } + +private: + size_type m_size; +}; + +} + +//------------------------------------------------------------------------------ + +template +struct ForwardListNode +{ + typedef typename PointerTraits ::template rebind_pointer ::type node_ptr; + + node_ptr next; +}; + +//------------------------------------------------------------------------------ + +// Provides value_traits for when T derives from Node +template +struct DerivedValueTraits +{ + typedef NodeTraits node_traits; + typedef T value_type; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef typename mpl::PointerToOther ::type pointer; + typedef typename mpl::PointerToOther ::type const_pointer; + typedef typename PointerTraits ::reference reference; + typedef typename PointerTraits ::reference const_reference; + + static node_ptr to_node_ptr (reference value) + { + return node_ptr (&value); + } + + static const_node_ptr to_node_ptr (const_reference value) + { + return node_ptr (&value); + } + + static pointer to_value_ptr (node_ptr const& n) + { + return pointer (&static_cast (*n)); + } + + static const_pointer to_value_ptr (const_node_ptr const &n) + { + return const_pointer (&static_cast (*n)); + } +}; + +//------------------------------------------------------------------------------ + +template +struct ForwardListNodeTraits +{ + typedef ForwardListNode node; + + typedef typename PointerTraits :: + template rebind_pointer node_ptr; + + typedef typename PointerTraits :: + template rebind_pointer const_node_ptr; + + static node_ptr get_next (const_node_ptr const& n) + { + return n->m_next; + } + + static node_ptr get_next (node_ptr const& n) + { + return n->m_next; + } + + static void set_next (node_ptr const& n, node_ptr const& next) + { + n->m_next = next; + } +}; + +//------------------------------------------------------------------------------ + +template +class ForwardListIterator + : public std::iterator < + std::forward_iterator_tag, + typename Container::value_type, + typename Container::difference_type, + typename mpl::IfConst ::type, + typename mpl::IfConst ::type> +{ +protected: + typedef typename Container::value_traits value_traits; + typedef typename Container::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename PointerTraits :: + template rebind_pointer ::type void_pointer; + +public: + typedef typename Container::value_type value_type; + typedef typename mpl::IfConst ::type pointer; + typedef typename mpl::IfConst ::type reference; + + ForwardListIterator () + : m_node () + { + } + + explicit ForwardListIterator (ForwardListIterator const& other) + : m_node (other.pointed_node ()) + { + } + + node_ptr const& pointed_node () const noexcept + { + return m_node; + } + + ForwardListIterator& operator= (node_ptr const& node) + { + m_node = node; + return static_cast (*this); + } + + ForwardListIterator& operator++ () + { + m_node = node_traits::get_next (m_node); + return static_cast (*this); + } + + ForwardListIterator operator++ (int) + { + ForwardListIterator result (*this); + m_node = node_traits::get_next (m_node); + return result; + } + + friend bool operator== (ForwardListIterator const& lhs, + ForwardListIterator const& rhs) + { + return lhs.m_node == rhs.m_node; + } + + friend bool operator!= (ForwardListIterator const& lhs, + ForwardListIterator const& rhs) + { + return ! (lhs == rhs); + } + + reference operator* () const + { + return *this->operator-> (); + } + + pointer operator-> () const + { + return value_traits::to_value_ptr (m_node); + } + +private: + node_ptr m_node; +}; + +//------------------------------------------------------------------------------ + +template +class ForwardListAlgorithms +{ +public: + typedef typename NodeTraits::node node; + typedef typename NodeTraits::node_ptr node_ptr; + typedef typename NodeTraits::const_node_ptr const_node_ptr; + typedef NodeTraits node_traits; + + static void init (node_ptr const& n) + { + NodeTraits::set_next (n, node_ptr()); + } + + static bool unique (const_node_ptr const& this_node) + { + node_ptr next = NodeTraits::get_next (this_node); + return !next || next == this_node; + } + + static void link_after (node_ptr const& prev_node, node_ptr const& this_node) + { + NodeTraits::set_next (this_node, NodeTraits::get_next (prev_node)); + NodeTraits::set_next (prev_node, this_node); + } + + static void unlink_after (node_ptr const& prev_node) + { + const_node_ptr this_node (NodeTraits::get_next (prev_node)); + NodeTraits::set_next (prev_node, NodeTraits::get_next (this_node)); + } +}; + +//------------------------------------------------------------------------------ + +/** Singly-linked intrusive list. */ +template +class ForwardList +{ +public: + typedef DerivedValueTraits > + value_traits; + typedef typename value_traits::pointer pointer; + typedef typename value_traits::const_pointer const_pointer; + typedef typename PointerTraits ::element_type value_type; + typedef typename PointerTraits ::reference reference; + typedef typename PointerTraits ::const_reference const_reference; + typedef typename PointerTraits ::difference_type difference_type; + typedef std::size_t size_type; + typedef ForwardListIterator iterator; + typedef ForwardListIterator const_iterator; + typedef typename value_traits::node_traits node_traits; + typedef typename node_traits::node node; + typedef typename node_traits::node_ptr node_ptr; + typedef typename node_traits::const_node_ptr const_node_ptr; + typedef ForwardListAlgorithms node_algorithms; + + typedef node Node; + +private: + typedef detail::SizeHolder size_traits; + + void default_construct () + { + get_size_traits ().set (size_type (0)); + node_algorithms::init (this->get_root_node ()); + } + + node_ptr get_end_node () + { + return node_ptr (); + } + + const_node_ptr get_end_node () const + { + return const_node_ptr (); + } + + node_ptr get_root_node () + { + return PointerTraits ::pointer_to (m_root); + } + + const_node_ptr get_root_node () const + { + return PointerTraits ::pointer_to (m_root); + } + + size_traits& get_size_traits () noexcept + { + return m_size; + } + + size_traits const& get_size_traits () const noexcept + { + return m_size; + } + + static node_ptr uncast (const_node_ptr const& ptr) + { + return PointerTraits ::const_cast_from (ptr); + } + +public: + ForwardList () + { + default_construct (); + } + + void clear () + { + default_construct (); + } + + void push_front (reference value) + { + node_ptr this_node (value_traits::to_node_ptr (value)); + node_algorithms::link_after (this->get_root_node (), this_node); + this->get_size_traits ().increment (); + } + + void pop_front () + { + //node_ptr this_node (node_traits::get_next (this->get_root ())); + node_algorithms::unlink_after (this->get_root_node ()); + this->get_size_traits ().decrement (); + } + + reference front () + { + return *value_traits::to_value_ptr (node_traits::get_next (this->get_root_node ())); + } + + const_reference front () const + { + return *value_traits::to_value_ptr (uncat (node_traits::get_next (this->get_root_node ()))); + } + + iterator begin () + { + return iterator (node_traits::get_next (this->get_root_node (), this)); + } + + const_iterator begin () const + { + return const_iterator (node_traits::get_next (this->get_root_node (), this)); + } + + const_iterator cbegin () const + { + return this->begin (); + } + + iterator end () + { + return iterator (this->get_end_node (), this); + } + + const_iterator end () const + { + return const_iterator (this->get_end_node (), this); + } + + const_iterator cend () const + { + return this->end (); + } + + iterator before_begin () + { + return iterator (this->get_root_node (), this); + } + + const_iterator before_begin () const + { + return const_iterator (this->get_root_node (), this); + } + + const_iterator cbefore_begin () const + { + return before_begin (); + } + + bool empty () const + { + return node_algorithms::unique (this->get_root_node ()); + } + + iterator iterator_to (reference value) + { + return iterator (value_traits::to_node_ptr (value), this); + } + + const_iterator iterator_to (const_reference value) const + { + return const_iterator (value_traits::to_node_ptr (const_cast (value)), this); + } + +private: + node m_root; + size_traits m_size; +}; + +} +} + +#endif diff --git a/beast/intrusive/PointerTraits.h b/beast/intrusive/PointerTraits.h new file mode 100644 index 0000000000..e4e733e38b --- /dev/null +++ b/beast/intrusive/PointerTraits.h @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED +#define BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED + +namespace beast { +namespace intrusive { + +// an unspecialized PointerTraits is ill-defined +template +struct PointerTraits; + +// specializations to remove cv-qualifiers +template +struct PointerTraits

: PointerTraits

{ }; +template +struct PointerTraits

: PointerTraits

{ }; +template +struct PointerTraits

: PointerTraits

{ }; +// specialization to remove a reference attribute +template +struct PointerTraits : PointerTraits

{ }; + +// specialization for raw pointers +template +struct PointerTraits +{ + typedef T element_type; + typedef T* pointer; + typedef T& reference; + typedef std::ptrdiff_t difference_type; + + template + struct rebind_pointer + { + typedef U* type; + }; + + static pointer pointer_to (reference r) + { + return static_cast ( + static_cast ( + const_cast ( + &reinterpret_cast ( + r)))); + } + + template + static pointer static_cast_from (U* u) + { + return static_cast (u); + } + + template + static pointer const_cast_from (U* u) + { + return const_cast (u); + } + + template + static pointer dynamic_cast_from (U* u) + { + return dynamic_cast (u); + } +}; + +} +} + +#endif diff --git a/beast/mpl.h b/beast/mpl.h new file mode 100644 index 0000000000..454f311741 --- /dev/null +++ b/beast/mpl.h @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_H_INCLUDED +#define BEAST_MPL_H_INCLUDED + +#include "mpl/AddConst.h" +#include "mpl/IfConst.h" +#include "mpl/PointerToOther.h" +#include "mpl/RemoveConst.h" +#include "mpl/RemoveConstVolatile.h" +#include "mpl/RemoveReference.h" +#include "mpl/RemoveVolatile.h" + +#endif diff --git a/beast/mpl/AddConst.h b/beast/mpl/AddConst.h new file mode 100644 index 0000000000..4b25ecd0bd --- /dev/null +++ b/beast/mpl/AddConst.h @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_ADDCONST_H_INCLUDED +#define BEAST_MPL_ADDCONST_H_INCLUDED + +// Ideas based on boost + +namespace beast { +namespace mpl { + +/// Add the `const` qualifier to a type. +template +struct AddConst +{ + typedef T const type; +}; + +} +} + +#endif diff --git a/beast/mpl/IfConst.h b/beast/mpl/IfConst.h new file mode 100644 index 0000000000..19f73b021a --- /dev/null +++ b/beast/mpl/IfConst.h @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_IFCONST_H_INCLUDED +#define BEAST_MPL_IFCONST_H_INCLUDED + +namespace beast { +namespace mpl { + +// Ideas based on boost + +/// Select between T1 or T2 depending on Condition. +/// @{ +template +struct IfConst +{ + typedef T1 type; +}; + +template +struct IfConst +{ + typedef T2 type; +}; +/// @} + +} +} + +#endif diff --git a/beast/mpl/PointerToOther.h b/beast/mpl/PointerToOther.h new file mode 100644 index 0000000000..868d46bb0f --- /dev/null +++ b/beast/mpl/PointerToOther.h @@ -0,0 +1,68 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_POINTERTOOTHERH_INCLUDED +#define BEAST_MPL_POINTERTOOTHERH_INCLUDED + +namespace beast { +namespace mpl { + +// Ideas based on boost + +/** Declares a type which is a pointer or smart pointer to U, depending on T. + This works for smart pointer containers with up to three template + parameters. More specializations can be added for containers with + more than three template parameters. +*/ +/// @{ +template +struct PointerToOther; + +template class SmartPointer> +struct PointerToOther , U> +{ + typedef SmartPointer type; +}; + +template class SmartPointer> +struct PointerToOther , U> +{ + typedef SmartPointer type; +}; + +template class SmartPointer> +struct PointerToOther , U> +{ + typedef SmartPointer type; +}; + +template +struct PointerToOther +{ + typedef U* type; +}; +/// @} + +} +} + +#endif diff --git a/beast/mpl/RemoveConst.h b/beast/mpl/RemoveConst.h new file mode 100644 index 0000000000..4f555f26a8 --- /dev/null +++ b/beast/mpl/RemoveConst.h @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_REMOVECONST_H_INCLUDED +#define BEAST_MPL_REMOVECONST_H_INCLUDED + +// Ideas based on boost + +namespace beast { +namespace mpl { + +/// Remove the `const` qualifier from a type. +/// @{ +template +struct RemoveConst +{ + typedef T type; +}; + +template +struct RemoveConst +{ + typedef T type; +}; +/// @} + +} +} + +#endif diff --git a/beast/mpl/RemoveConstVolatile.h b/beast/mpl/RemoveConstVolatile.h new file mode 100644 index 0000000000..361f0255ac --- /dev/null +++ b/beast/mpl/RemoveConstVolatile.h @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_REMOVECONSTVOLATILE_H_INCLUDED +#define BEAST_MPL_REMOVECONSTVOLATILE_H_INCLUDED + +#include "RemoveConst.h" +#include "RemoveVolatile.h" + +// Ideas based on boost + +namespace beast { +namespace mpl { + +/// Remove both the `const` and `volatile` qualifiers from a type. +template +struct RemoveConstVolatile +{ + typedef typename RemoveConst < + typename RemoveVolatile ::type + >::type type; +}; + +} +} + +#endif diff --git a/beast/mpl/RemoveReference.h b/beast/mpl/RemoveReference.h new file mode 100644 index 0000000000..239addcca7 --- /dev/null +++ b/beast/mpl/RemoveReference.h @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_REMOVEREFERENCE_H_INCLUDED +#define BEAST_MPL_REMOVEREFERENCE_H_INCLUDED + +namespace beast { +namespace mpl { + +// Ideas based on boost + +/// Remove the reference qualifier from a type. +/// @{ +template +struct RemoveReference +{ + typedef T type; +}; + +template +struct RemoveReference +{ + typedef T type; +}; +/// @} + +} +} + +#endif diff --git a/beast/mpl/RemoveVolatile.h b/beast/mpl/RemoveVolatile.h new file mode 100644 index 0000000000..26a848724e --- /dev/null +++ b/beast/mpl/RemoveVolatile.h @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_REMOVEVOLATILE_H_INCLUDED +#define BEAST_MPL_REMOVEVOLATILE_H_INCLUDED + +// Ideas based on boost + +namespace beast { +namespace mpl { + +/// Remove the `volatile` qualifier from a type. +/// @{ +template +struct RemoveVolatile +{ + typedef T type; +}; + +template +struct RemoveVolatile +{ + typedef T type; +}; +/// @} + +} +} + +#endif diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h index babc3c9e7b..d15b155c9e 100644 --- a/modules/beast_core/beast_core.h +++ b/modules/beast_core/beast_core.h @@ -218,6 +218,13 @@ Some files contain portions of these external projects, licensed separately: #undef _aligned_msize #endif +//------------------------------------------------------------------------------ + +// New header-only library modeled more closely according to boost +#include "../../beast/intrusive/ForwardList.h" + +//------------------------------------------------------------------------------ + namespace beast { @@ -445,6 +452,4 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n #pragma warning (pop) #endif -//------------------------------------------------------------------------------ - #endif