|
Boost-Commit : |
From: oryol_at_[hidden]
Date: 2008-08-20 18:01:36
Author: jeremypack
Date: 2008-08-20 18:01:36 EDT (Wed, 20 Aug 2008)
New Revision: 48271
URL: http://svn.boost.org/trac/boost/changeset/48271
Log:
Add size() and empty() to type_map.
Text files modified:
sandbox/boost/extension/type_map.hpp | 21 +++++++++++++++++++++
sandbox/libs/extension/test/type_map_test.cpp | 4 ++++
2 files changed, 25 insertions(+), 0 deletions(-)
Modified: sandbox/boost/extension/type_map.hpp
==============================================================================
--- sandbox/boost/extension/type_map.hpp (original)
+++ sandbox/boost/extension/type_map.hpp 2008-08-20 18:01:36 EDT (Wed, 20 Aug 2008)
@@ -53,6 +53,7 @@
#ifndef BOOST_EXTENSION_DOXYGEN_INVOKED
class type_map_convertible {
public:
+ friend class basic_type_map<TypeInfo>;
~type_map_convertible() {
for (typename std::map<TypeInfo, generic_type_holder*>::iterator
it =instances_.begin(); it != instances_.end(); ++it) {
@@ -92,6 +93,14 @@
std::map<TypeInfo, generic_type_holder*> instances_;
};
+ size_t size() {
+ return convertible_.instances_.size();
+ }
+
+ bool empty() {
+ return convertible_.instances_.empty();
+ }
+
type_map_convertible& get() {
return convertible_;
}
@@ -123,6 +132,18 @@
*/
typedef basic_type_map<default_type_info> type_map;
+/** A macro to use as a generic
+ * function declaration for
+ * functions in shared libraries
+ * taking a reference to type_map
+ * and returning void.
+ */
+#define BOOST_EXTENSION_TYPE_MAP_FUNCTION \
+extern "C" \
+void BOOST_EXTENSION_EXPORT_DECL \
+boost_extension_exported_type_map_function \
+ (boost::extensions::type_map& types)
+
} // namespace extensions
} // namespace boost
Modified: sandbox/libs/extension/test/type_map_test.cpp
==============================================================================
--- sandbox/libs/extension/test/type_map_test.cpp (original)
+++ sandbox/libs/extension/test/type_map_test.cpp 2008-08-20 18:01:36 EDT (Wed, 20 Aug 2008)
@@ -38,8 +38,12 @@
BOOST_AUTO_TEST_CASE(constTest) {
type_map m;
+ BOOST_CHECK(m.empty());
int& my_int(m.get());
my_int = 5;
const int& my_const_int(m.get());
BOOST_CHECK_EQUAL(my_const_int, 5);
+ // Make sure there is only one element.
+ BOOST_CHECK_EQUAL(m.size(), size_t(1));
+ BOOST_CHECK(!m.empty());
}
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