|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80968 - in sandbox/type_erasure: boost/type_erasure libs/type_erasure/test
From: steven_at_[hidden]
Date: 2012-10-12 16:25:51
Author: steven_watanabe
Date: 2012-10-12 16:25:51 EDT (Fri, 12 Oct 2012)
New Revision: 80968
URL: http://svn.boost.org/trac/boost/changeset/80968
Log:
Add is_empty.
Added:
sandbox/type_erasure/boost/type_erasure/is_empty.hpp (contents, props changed)
sandbox/type_erasure/libs/type_erasure/test/test_is_empty.cpp (contents, props changed)
Text files modified:
sandbox/type_erasure/libs/type_erasure/test/Jamfile.jam | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Added: sandbox/type_erasure/boost/type_erasure/is_empty.hpp
==============================================================================
--- (empty file)
+++ sandbox/type_erasure/boost/type_erasure/is_empty.hpp 2012-10-12 16:25:51 EDT (Fri, 12 Oct 2012)
@@ -0,0 +1,28 @@
+// Boost.TypeErasure library
+//
+// Copyright 2012 Steven Watanabe
+//
+// 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)
+//
+// $Id$
+
+#ifndef BOOST_TYPE_ERASURE_IS_EMPTY_HPP_INCLUDED
+#define BOOST_TYPE_ERASURE_IS_EMPTY_HPP_INCLUDED
+
+#include <boost/type_erasure/detail/access.hpp>
+
+namespace boost {
+namespace type_erasure {
+
+/** Returns true for an empty @ref any. */
+template<class T>
+bool is_empty(const T& arg) {
+ return ::boost::type_erasure::detail::access::data(arg).data == 0;
+}
+
+}
+}
+
+#endif
Modified: sandbox/type_erasure/libs/type_erasure/test/Jamfile.jam
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/test/Jamfile.jam (original)
+++ sandbox/type_erasure/libs/type_erasure/test/Jamfile.jam 2012-10-12 16:25:51 EDT (Fri, 12 Oct 2012)
@@ -36,6 +36,7 @@
run test_member.cpp /boost//unit_test_framework ;
run test_null.cpp /boost//unit_test_framework ;
run test_free.cpp /boost//unit_test_framework ;
+run test_is_empty.cpp /boost//unit_test_framework ;
compile test_param.cpp ;
compile test_is_subconcept.cpp ;
Added: sandbox/type_erasure/libs/type_erasure/test/test_is_empty.cpp
==============================================================================
--- (empty file)
+++ sandbox/type_erasure/libs/type_erasure/test/test_is_empty.cpp 2012-10-12 16:25:51 EDT (Fri, 12 Oct 2012)
@@ -0,0 +1,35 @@
+// Boost.TypeErasure library
+//
+// Copyright 2011 Steven Watanabe
+//
+// 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)
+//
+// $Id$
+
+#include <boost/type_erasure/any.hpp>
+#include <boost/type_erasure/is_empty.hpp>
+#include <boost/type_erasure/builtin.hpp>
+#include <boost/mpl/vector.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using namespace boost::type_erasure;
+
+BOOST_AUTO_TEST_CASE(test_non_relaxed)
+{
+ typedef copy_constructible<> test_concept;
+ any<test_concept> x(2);
+ BOOST_CHECK(!is_empty(x));
+}
+
+BOOST_AUTO_TEST_CASE(test_relaxed)
+{
+ typedef boost::mpl::vector<copy_constructible<>, relaxed_match> test_concept;
+ any<test_concept> x(2);
+ BOOST_CHECK(!is_empty(x));
+ any<test_concept> y;
+ BOOST_CHECK(is_empty(y));
+}
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