Boost logo

Boost-Commit :

From: troy_at_[hidden]
Date: 2008-07-01 14:25:16


Author: troy
Date: 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
New Revision: 46975
URL: http://svn.boost.org/trac/boost/changeset/46975

Log:
modularize any
Added:
   branches/CMake/release/libs/any/include/
   branches/CMake/release/libs/any/include/boost/
   branches/CMake/release/libs/any/include/boost/any.hpp (contents, props changed)
   branches/CMake/release/libs/any/module.cmake (contents, props changed)
Removed:
   branches/CMake/release/boost/any.hpp
Text files modified:
   branches/CMake/release/libs/any/CMakeLists.txt | 6 ++++--
   branches/CMake/release/libs/any/test/CMakeLists.txt | 1 +
   2 files changed, 5 insertions(+), 2 deletions(-)

Deleted: branches/CMake/release/boost/any.hpp
==============================================================================
--- branches/CMake/release/boost/any.hpp 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
+++ (empty file)
@@ -1,235 +0,0 @@
-// See http://www.boost.org/libs/any for Documentation.
-
-#ifndef BOOST_ANY_INCLUDED
-#define BOOST_ANY_INCLUDED
-
-// what: variant type boost::any
-// who: contributed by Kevlin Henney,
-// with features contributed and bugs found by
-// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
-// when: July 2001
-// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
-
-#include <algorithm>
-#include <typeinfo>
-
-#include "boost/config.hpp"
-#include <boost/type_traits/remove_reference.hpp>
-#include <boost/type_traits/is_reference.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/static_assert.hpp>
-
-namespace boost
-{
- class any
- {
- public: // structors
-
- any()
- : content(0)
- {
- }
-
- template<typename ValueType>
- any(const ValueType & value)
- : content(new holder<ValueType>(value))
- {
- }
-
- any(const any & other)
- : content(other.content ? other.content->clone() : 0)
- {
- }
-
- ~any()
- {
- delete content;
- }
-
- public: // modifiers
-
- any & swap(any & rhs)
- {
- std::swap(content, rhs.content);
- return *this;
- }
-
- template<typename ValueType>
- any & operator=(const ValueType & rhs)
- {
- any(rhs).swap(*this);
- return *this;
- }
-
- any & operator=(const any & rhs)
- {
- any(rhs).swap(*this);
- return *this;
- }
-
- public: // queries
-
- bool empty() const
- {
- return !content;
- }
-
- const std::type_info & type() const
- {
- return content ? content->type() : typeid(void);
- }
-
-#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
- private: // types
-#else
- public: // types (public so any_cast can be non-friend)
-#endif
-
- class placeholder
- {
- public: // structors
-
- virtual ~placeholder()
- {
- }
-
- public: // queries
-
- virtual const std::type_info & type() const = 0;
-
- virtual placeholder * clone() const = 0;
-
- };
-
- template<typename ValueType>
- class holder : public placeholder
- {
- public: // structors
-
- holder(const ValueType & value)
- : held(value)
- {
- }
-
- public: // queries
-
- virtual const std::type_info & type() const
- {
- return typeid(ValueType);
- }
-
- virtual placeholder * clone() const
- {
- return new holder(held);
- }
-
- public: // representation
-
- ValueType held;
-
- };
-
-#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
-
- private: // representation
-
- template<typename ValueType>
- friend ValueType * any_cast(any *);
-
- template<typename ValueType>
- friend ValueType * unsafe_any_cast(any *);
-
-#else
-
- public: // representation (public so any_cast can be non-friend)
-
-#endif
-
- placeholder * content;
-
- };
-
- class bad_any_cast : public std::bad_cast
- {
- public:
- virtual const char * what() const throw()
- {
- return "boost::bad_any_cast: "
- "failed conversion using boost::any_cast";
- }
- };
-
- template<typename ValueType>
- ValueType * any_cast(any * operand)
- {
- return operand && operand->type() == typeid(ValueType)
- ? &static_cast<any::holder<ValueType> *>(operand->content)->held
- : 0;
- }
-
- template<typename ValueType>
- inline const ValueType * any_cast(const any * operand)
- {
- return any_cast<ValueType>(const_cast<any *>(operand));
- }
-
- template<typename ValueType>
- ValueType any_cast(any & operand)
- {
- typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
-
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- // If 'nonref' is still reference type, it means the user has not
- // specialized 'remove_reference'.
-
- // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro
- // to generate specialization of remove_reference for your class
- // See type traits library documentation for details
- BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
-#endif
-
- nonref * result = any_cast<nonref>(&operand);
- if(!result)
- boost::throw_exception(bad_any_cast());
- return *result;
- }
-
- template<typename ValueType>
- inline ValueType any_cast(const any & operand)
- {
- typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
-
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- // The comment in the above version of 'any_cast' explains when this
- // assert is fired and what to do.
- BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
-#endif
-
- return any_cast<const nonref &>(const_cast<any &>(operand));
- }
-
- // Note: The "unsafe" versions of any_cast are not part of the
- // public interface and may be removed at any time. They are
- // required where we know what type is stored in the any and can't
- // use typeid() comparison, e.g., when our types may travel across
- // different shared libraries.
- template<typename ValueType>
- inline ValueType * unsafe_any_cast(any * operand)
- {
- return &static_cast<any::holder<ValueType> *>(operand->content)->held;
- }
-
- template<typename ValueType>
- inline const ValueType * unsafe_any_cast(const any * operand)
- {
- return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
- }
-}
-
-// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
-//
-// 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)
-
-#endif

Modified: branches/CMake/release/libs/any/CMakeLists.txt
==============================================================================
--- branches/CMake/release/libs/any/CMakeLists.txt (original)
+++ branches/CMake/release/libs/any/CMakeLists.txt 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
@@ -1,6 +1,8 @@
 boost_library_project(
- Asio
- HEADERS asio.hpp asio
+ Any
+ TESTDIRS test
+ HEADERS any.hpp
+ MODULAR
 )
 
 

Added: branches/CMake/release/libs/any/include/boost/any.hpp
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/any/include/boost/any.hpp 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
@@ -0,0 +1,235 @@
+// See http://www.boost.org/libs/any for Documentation.
+
+#ifndef BOOST_ANY_INCLUDED
+#define BOOST_ANY_INCLUDED
+
+// what: variant type boost::any
+// who: contributed by Kevlin Henney,
+// with features contributed and bugs found by
+// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
+// when: July 2001
+// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
+
+#include <algorithm>
+#include <typeinfo>
+
+#include "boost/config.hpp"
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/static_assert.hpp>
+
+namespace boost
+{
+ class any
+ {
+ public: // structors
+
+ any()
+ : content(0)
+ {
+ }
+
+ template<typename ValueType>
+ any(const ValueType & value)
+ : content(new holder<ValueType>(value))
+ {
+ }
+
+ any(const any & other)
+ : content(other.content ? other.content->clone() : 0)
+ {
+ }
+
+ ~any()
+ {
+ delete content;
+ }
+
+ public: // modifiers
+
+ any & swap(any & rhs)
+ {
+ std::swap(content, rhs.content);
+ return *this;
+ }
+
+ template<typename ValueType>
+ any & operator=(const ValueType & rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ any & operator=(const any & rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ public: // queries
+
+ bool empty() const
+ {
+ return !content;
+ }
+
+ const std::type_info & type() const
+ {
+ return content ? content->type() : typeid(void);
+ }
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+ private: // types
+#else
+ public: // types (public so any_cast can be non-friend)
+#endif
+
+ class placeholder
+ {
+ public: // structors
+
+ virtual ~placeholder()
+ {
+ }
+
+ public: // queries
+
+ virtual const std::type_info & type() const = 0;
+
+ virtual placeholder * clone() const = 0;
+
+ };
+
+ template<typename ValueType>
+ class holder : public placeholder
+ {
+ public: // structors
+
+ holder(const ValueType & value)
+ : held(value)
+ {
+ }
+
+ public: // queries
+
+ virtual const std::type_info & type() const
+ {
+ return typeid(ValueType);
+ }
+
+ virtual placeholder * clone() const
+ {
+ return new holder(held);
+ }
+
+ public: // representation
+
+ ValueType held;
+
+ };
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+
+ private: // representation
+
+ template<typename ValueType>
+ friend ValueType * any_cast(any *);
+
+ template<typename ValueType>
+ friend ValueType * unsafe_any_cast(any *);
+
+#else
+
+ public: // representation (public so any_cast can be non-friend)
+
+#endif
+
+ placeholder * content;
+
+ };
+
+ class bad_any_cast : public std::bad_cast
+ {
+ public:
+ virtual const char * what() const throw()
+ {
+ return "boost::bad_any_cast: "
+ "failed conversion using boost::any_cast";
+ }
+ };
+
+ template<typename ValueType>
+ ValueType * any_cast(any * operand)
+ {
+ return operand && operand->type() == typeid(ValueType)
+ ? &static_cast<any::holder<ValueType> *>(operand->content)->held
+ : 0;
+ }
+
+ template<typename ValueType>
+ inline const ValueType * any_cast(const any * operand)
+ {
+ return any_cast<ValueType>(const_cast<any *>(operand));
+ }
+
+ template<typename ValueType>
+ ValueType any_cast(any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ // If 'nonref' is still reference type, it means the user has not
+ // specialized 'remove_reference'.
+
+ // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro
+ // to generate specialization of remove_reference for your class
+ // See type traits library documentation for details
+ BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
+#endif
+
+ nonref * result = any_cast<nonref>(&operand);
+ if(!result)
+ boost::throw_exception(bad_any_cast());
+ return *result;
+ }
+
+ template<typename ValueType>
+ inline ValueType any_cast(const any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ // The comment in the above version of 'any_cast' explains when this
+ // assert is fired and what to do.
+ BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
+#endif
+
+ return any_cast<const nonref &>(const_cast<any &>(operand));
+ }
+
+ // Note: The "unsafe" versions of any_cast are not part of the
+ // public interface and may be removed at any time. They are
+ // required where we know what type is stored in the any and can't
+ // use typeid() comparison, e.g., when our types may travel across
+ // different shared libraries.
+ template<typename ValueType>
+ inline ValueType * unsafe_any_cast(any * operand)
+ {
+ return &static_cast<any::holder<ValueType> *>(operand->content)->held;
+ }
+
+ template<typename ValueType>
+ inline const ValueType * unsafe_any_cast(const any * operand)
+ {
+ return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
+ }
+}
+
+// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
+//
+// 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)
+
+#endif

Added: branches/CMake/release/libs/any/module.cmake
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/any/module.cmake 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
@@ -0,0 +1,2 @@
+boost_module(any)
+

Modified: branches/CMake/release/libs/any/test/CMakeLists.txt
==============================================================================
--- branches/CMake/release/libs/any/test/CMakeLists.txt (original)
+++ branches/CMake/release/libs/any/test/CMakeLists.txt 2008-07-01 14:25:15 EDT (Tue, 01 Jul 2008)
@@ -1,2 +1,3 @@
 boost_test_run(any_test ../any_test.cpp)
+boost_test_compile_fail(any_cast_cv_failed)
 


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