$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: steven_at_[hidden]
Date: 2007-11-19 10:53:49
Author: steven_watanabe
Date: 2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
New Revision: 41229
URL: http://svn.boost.org/trac/boost/changeset/41229
Log:
Fixed more problems with forced_return
Added:
   sandbox/switch/libs/switch/test/test_odr1.cpp   (contents, props changed)
   sandbox/switch/libs/switch/test/test_odr2.cpp   (contents, props changed)
Text files modified: 
   sandbox/switch/boost/switch.hpp                 |    11 +++++++++--                             
   sandbox/switch/libs/switch/test/Jamfile.v2      |     3 ++-                                     
   sandbox/switch/libs/switch/test/test_switch.cpp |    26 ++++++++++++++++++++++----              
   3 files changed, 33 insertions(+), 7 deletions(-)
Modified: sandbox/switch/boost/switch.hpp
==============================================================================
--- sandbox/switch/boost/switch.hpp	(original)
+++ sandbox/switch/boost/switch.hpp	2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
@@ -20,6 +20,7 @@
 #include <boost/preprocessor/iteration/local.hpp>
 #include <boost/mpl/size.hpp>
 #include <boost/mpl/at.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 
 #ifndef BOOST_SWITCH_LIMIT
     #define BOOST_SWITCH_LIMIT 50
@@ -50,13 +51,19 @@
 // default is supplied.
 
 template<class R>
-R forced_return(R* r = 0) {
+inline R forced_return(typename boost::remove_reference<R>::type* r = 0) {
     return(*r);
 }
 
 // Thanks to Stjepan Rajko for catching this.
 template<>
-void forced_return<void>(void*) {}
+inline void forced_return<void>(void*) {}
+template<>
+inline const void forced_return<const void>(const void*) {}
+template<>
+inline volatile void forced_return<volatile void>(volatile void*) {}
+template<>
+inline const volatile void forced_return<const volatile void>(const volatile void*) {}
 
 template<class R>
 struct throw_exception {
Modified: sandbox/switch/libs/switch/test/Jamfile.v2
==============================================================================
--- sandbox/switch/libs/switch/test/Jamfile.v2	(original)
+++ sandbox/switch/libs/switch/test/Jamfile.v2	2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
@@ -10,7 +10,7 @@
 import testing ;
 
 project switch_test : :
-    requirements <include>../../.. <warnings>all
+    requirements <include>../../.. <include>$(BOOST_ROOT) <warnings>all
 ;
 
 
@@ -18,5 +18,6 @@
   test-suite switch_:
    :
     [ run test_switch.cpp $(BOOST_ROOT)/libs/test/build//boost_unit_test_framework : : : : ]
+    [ link test_odr1.cpp test_odr2.cpp ]
    ;
 }
Added: sandbox/switch/libs/switch/test/test_odr1.cpp
==============================================================================
--- (empty file)
+++ sandbox/switch/libs/switch/test/test_odr1.cpp	2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,12 @@
+// test_odr1.cpp
+//
+// Copyright (c) 2007
+// 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)
+
+#include <boost/switch.hpp>
+
+int main() {}
Added: sandbox/switch/libs/switch/test/test_odr2.cpp
==============================================================================
--- (empty file)
+++ sandbox/switch/libs/switch/test/test_odr2.cpp	2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
@@ -0,0 +1,10 @@
+// test_odr1.cpp
+//
+// Copyright (c) 2007
+// 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)
+
+#include <boost/switch.hpp>
Modified: sandbox/switch/libs/switch/test/test_switch.cpp
==============================================================================
--- sandbox/switch/libs/switch/test/test_switch.cpp	(original)
+++ sandbox/switch/libs/switch/test/test_switch.cpp	2007-11-19 10:53:48 EST (Mon, 19 Nov 2007)
@@ -34,20 +34,31 @@
     struct limit_test {
         typedef int result_type;
         template<class Index>
-        int operator()(Index) {
+        int operator()(Index) const {
             return(-Index::value);
         }
     };
     typedef boost::mpl::range_c<int, 0, BOOST_SWITCH_LIMIT> limit_range;
     const int limit_value = BOOST_SWITCH_LIMIT - 1;
 
+    template<class T>
     struct void_return {
-        typedef void result_type;
+        typedef T result_type;
         template<class Index>
-        void operator()(Index) {
+        T operator()(Index) const {
             // Do Nothing.
         }
     };
+
+    int test_int;
+
+    struct return_reference {
+        typedef int& result_type;
+        template<class Index>
+        int& operator()(Index) const {
+            return(test_int);
+        }
+    };
 }
 
 BOOST_AUTO_TEST_CASE(without_default) {
@@ -109,5 +120,12 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_void) {
-    boost::switch_<test_range>(0, void_return());
+    boost::switch_<test_range>(0, void_return<void>());
+    boost::switch_<test_range>(0, void_return<const void>());
+    boost::switch_<test_range>(0, void_return<volatile void>());
+    boost::switch_<test_range>(0, void_return<const volatile void>());
+}
+
+BOOST_AUTO_TEST_CASE(test_reference) {
+    boost::switch_<test_range>(0, return_reference());
 }