$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70530 - sandbox/local/libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-03-24 17:34:03
Author: lcaminiti
Date: 2011-03-24 17:34:02 EDT (Thu, 24 Mar 2011)
New Revision: 70530
URL: http://svn.boost.org/trac/boost/changeset/70530
Log:
Changed function template examples into class template examples to workaround an MSVC bug with using `typename`.
Text files modified: 
   sandbox/local/libs/local/example/typeof_tpl.cpp    |    74 ++++++++++++++++++++------------------- 
   sandbox/local/libs/local/example/typeof_tpl_va.cpp |    74 ++++++++++++++++++++------------------- 
   2 files changed, 76 insertions(+), 72 deletions(-)
Modified: sandbox/local/libs/local/example/typeof_tpl.cpp
==============================================================================
--- sandbox/local/libs/local/example/typeof_tpl.cpp	(original)
+++ sandbox/local/libs/local/example/typeof_tpl.cpp	2011-03-24 17:34:02 EDT (Thu, 24 Mar 2011)
@@ -15,44 +15,46 @@
 #include <cassert>
 
 template<typename T>
-T total(const T& x, const T& y, const T& z) {
-    T sum = T();
-    int factor = 10;
-
-    T BOOST_LOCAL_FUNCTION_PARAMS_TPL( (T num) (const bind factor)
-            (bind& sum) ) {
-        // Typeof for variable declaration.
-        BOOST_LOCAL_TYPEOF(factor) f = factor;
-        return sum += f * num;
-    } BOOST_LOCAL_FUNCTION_NAME(add)
-    add(x);
-
-    size_t size = 2;
-    T* nums = new T[size];
-    BOOST_LOCAL_EXIT_TPL( (const bind& size) (bind nums) ) {
-        // Typeof is qualified with eventual bind's `const` and `&`.
-        boost::remove_const<boost::remove_reference<
-                BOOST_LOCAL_TYPEOF(size)>::type>::type s;
-        s = size;
-        if (s && nums) delete[] nums;
-    } BOOST_LOCAL_EXIT_END
-
-    nums[0] = y; nums[1] = z;
-    std::for_each(nums, nums + size, add);
-
-    BOOST_LOCAL_BLOCK_TPL( (const bind &sum) (const bind& factor)
-            (const bind& x) (const bind& y) (const bind& z) ) {
-        // Typeof for concept checking.
-        BOOST_CONCEPT_ASSERT((boost::EqualityComparable<
-                BOOST_LOCAL_TYPEOF(sum)>));
-        assert(sum == factor * (x + y + z));
-    } BOOST_LOCAL_BLOCK_END
-
-    return sum;
-}
+struct calculator {
+    static T total(const T& x, const T& y, const T& z) {
+        T sum = T();
+        int factor = 10;
+
+        T BOOST_LOCAL_FUNCTION_PARAMS_TPL( (T num) (const bind factor)
+                (bind& sum) ) {
+            // Typeof for variable declaration.
+            BOOST_LOCAL_TYPEOF(factor) f = factor;
+            return sum += f * num;
+        } BOOST_LOCAL_FUNCTION_NAME(add)
+        add(x);
+
+        size_t size = 2;
+        T* nums = new T[size];
+        BOOST_LOCAL_EXIT_TPL( (const bind& size) (bind nums) ) {
+            // Typeof is qualified with eventual bind's `const` and `&`.
+            typename boost::remove_const<typename boost::remove_reference<
+                    BOOST_LOCAL_TYPEOF(size)>::type>::type s;
+            s = size;
+            if (s && nums) delete[] nums;
+        } BOOST_LOCAL_EXIT_END
+
+        nums[0] = y; nums[1] = z;
+        std::for_each(nums, nums + size, add);
+
+        BOOST_LOCAL_BLOCK_TPL( (const bind &sum) (const bind& factor)
+                (const bind& x) (const bind& y) (const bind& z) ) {
+            // Typeof for concept checking.
+            BOOST_CONCEPT_ASSERT((boost::EqualityComparable<
+                    BOOST_LOCAL_TYPEOF(sum)>));
+            assert(sum == factor * (x + y + z));
+        } BOOST_LOCAL_BLOCK_END
+
+        return sum;
+    }
+};
 
 int main() {
-    total(100.0, 90.5, 7.0);
+    calculator<double>::total(100.0, 90.5, 7.0);
     return 0;
 }
 //]
Modified: sandbox/local/libs/local/example/typeof_tpl_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/typeof_tpl_va.cpp	(original)
+++ sandbox/local/libs/local/example/typeof_tpl_va.cpp	2011-03-24 17:34:02 EDT (Thu, 24 Mar 2011)
@@ -15,44 +15,46 @@
 #include <cassert>
 
 template<typename T>
-T total(const T& x, const T& y, const T& z) {
-    T sum = T();
-    int factor = 10;
-
-    T BOOST_LOCAL_FUNCTION_PARAMS_TPL(T num, const bind factor,
-            bind& sum) {
-        // Typeof for variable declaratin.
-        BOOST_LOCAL_TYPEOF(factor) f = factor;
-        return sum += f * num;
-    } BOOST_LOCAL_FUNCTION_NAME(add)
-    add(x);
-
-    size_t size = 2;
-    T* nums = new T[size];
-    BOOST_LOCAL_EXIT_TPL(const bind& size, bind nums) {
-        // Typeof is qualified with eventual bind's `const` and `&`.
-        boost::remove_const<boost::remove_reference<
-                BOOST_LOCAL_TYPEOF(size)>::type>::type s;
-        s = size;
-        if (s && nums) delete[] nums;
-    } BOOST_LOCAL_EXIT_END
-
-    nums[0] = y; nums[1] = z;
-    std::for_each(nums, nums + size, add);
-
-    BOOST_LOCAL_BLOCK_TPL(const bind &sum, const bind& factor,
-            const bind& x, const bind& y, const bind& z) {
-        // Tyepof for concept checking.
-        BOOST_CONCEPT_ASSERT((boost::EqualityComparable<
-                BOOST_LOCAL_TYPEOF(sum)>));
-        assert(sum == factor * (x + y + z));
-    } BOOST_LOCAL_BLOCK_END
-
-    return sum;
-}
+struct calculator {
+    static T total(const T& x, const T& y, const T& z) {
+        T sum = T();
+        int factor = 10;
+
+        T BOOST_LOCAL_FUNCTION_PARAMS_TPL(T num, const bind factor,
+                bind& sum) {
+            // Typeof for variable declaratin.
+            BOOST_LOCAL_TYPEOF(factor) f = factor;
+            return sum += f * num;
+        } BOOST_LOCAL_FUNCTION_NAME(add)
+        add(x);
+
+        size_t size = 2;
+        T* nums = new T[size];
+        BOOST_LOCAL_EXIT_TPL(const bind& size, bind nums) {
+            // Typeof is qualified with eventual bind's `const` and `&`.
+            typename boost::remove_const<typename boost::remove_reference<
+                    BOOST_LOCAL_TYPEOF(size)>::type>::type s;
+            s = size;
+            if (s && nums) delete[] nums;
+        } BOOST_LOCAL_EXIT_END
+
+        nums[0] = y; nums[1] = z;
+        std::for_each(nums, nums + size, add);
+
+        BOOST_LOCAL_BLOCK_TPL(const bind &sum, const bind& factor,
+                const bind& x, const bind& y, const bind& z) {
+            // Tyepof for concept checking.
+            BOOST_CONCEPT_ASSERT((boost::EqualityComparable<
+                    BOOST_LOCAL_TYPEOF(sum)>));
+            assert(sum == factor * (x + y + z));
+        } BOOST_LOCAL_BLOCK_END
+
+        return sum;
+    }
+};
 
 int main() {
-    total(100.0, 90.5, 7.0);
+    calculator<double>::total(100.0, 90.5, 7.0);
     return 0;
 }
 //]