|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71965 - sandbox/local/libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-05-15 19:53:01
Author: lcaminiti
Date: 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
New Revision: 71965
URL: http://svn.boost.org/trac/boost/changeset/71965
Log:
Fixed C++0x comparison examples.
Added:
sandbox/local/libs/local/example/expensive_copy_0x_lambda.cpp (contents, props changed)
sandbox/local/libs/local/example/expensive_copy_boost_local.cpp (contents, props changed)
sandbox/local/libs/local/example/expensive_copy_boost_local_va.cpp (contents, props changed)
sandbox/local/libs/local/example/noncopyable_0x_lambda.cpp (contents, props changed)
sandbox/local/libs/local/example/noncopyable_boost_local.cpp (contents, props changed)
sandbox/local/libs/local/example/noncopyable_boost_local_va.cpp (contents, props changed)
Added: sandbox/local/libs/local/example/expensive_copy_0x_lambda.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/expensive_copy_0x_lambda.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,37 @@
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_LAMBDAS
+#include <iostream>
+int main() {
+ std::cerr << "Error: This program requires C++0x lambdas" << std::endl;
+ return 0;
+}
+#else
+
+//[expensive_copy_0x_lambda_cpp
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t {
+ int i;
+ x_t(int _i): i(_i) {}
+ x_t(x_t const& o): i(o.i) { // Some time consuming copy.
+ for (unsigned long i = 0; i < 10000000000; ++i);
+ }
+};
+
+int main() {
+ x_t x(-1);
+
+ auto l = [x]() { // Expensive copy...
+ // ... but if bind `&x` then `x` is not constant.
+ std::cout << x.i << std::endl;
+ };
+ l();
+
+ return 0;
+}
+//]
+
+#endif
+
Added: sandbox/local/libs/local/example/expensive_copy_boost_local.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/expensive_copy_boost_local.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,26 @@
+
+//[expensive_copy_boost_local_cpp
+#include <boost/local/function.hpp>
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t {
+ int i;
+ x_t(int _i): i(_i) {}
+ x_t(x_t const& o): i(o.i) { // Some time consuming copy.
+ for (unsigned long i = 0; i < 10000000000; ++i);
+ }
+};
+
+int main() {
+ x_t x(-1);
+
+ void BOOST_LOCAL_FUNCTION_PARAMS( (const bind& x) ) { // No copy...
+ std::cout << x.i << std::endl; // ... and constant.
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/expensive_copy_boost_local_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/expensive_copy_boost_local_va.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,37 @@
+
+#include <boost/config.hpp>
+#if defined(BOOST_NO_VARIADIC_MACROS) || defined(BOOST_LOCAL_CONFIG_COMPLIANT)
+#include <iostream>
+int main() {
+ std::cerr << "Error: This program requires variadic macros" << std::endl;
+ return 0;
+}
+#else
+
+//[expensive_copy_boost_local_va_cpp
+#include <boost/local/function.hpp>
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t {
+ int i;
+ x_t(int _i): i(_i) {}
+ x_t(x_t const& o): i(o.i) { // Some time consuming copy.
+ for (unsigned long i = 0; i < 10000000000; ++i);
+ }
+};
+
+int main() {
+ x_t x(-1);
+
+ void BOOST_LOCAL_FUNCTION_PARAMS(const bind& x) { // No copy...
+ std::cout << x.i << std::endl; // ... and constant.
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ return 0;
+}
+//]
+
+#endif
+
Added: sandbox/local/libs/local/example/noncopyable_0x_lambda.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/noncopyable_0x_lambda.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,25 @@
+
+// This code does NOT compile -- don't add it to the build.
+
+//[noncopyable_0x_lambda_cpp
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t: boost::noncopyable {
+ int i;
+ x_t(int _i): i(_i) {}
+};
+
+int main() {
+ x_t x(-1);
+
+ auto l = [x]() { // Error: x is non copyable...
+ // ... but if bind `&x` then `x` is not constant.
+ std::cout << x.i << std::endl;
+ };
+ l();
+
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/noncopyable_boost_local.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/noncopyable_boost_local.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,23 @@
+
+//[noncopyable_boost_local_cpp
+#include <boost/local/function.hpp>
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t: boost::noncopyable {
+ int i;
+ x_t(int _i): i(_i) {}
+};
+
+int main() {
+ x_t x(-1);
+
+ void BOOST_LOCAL_FUNCTION_PARAMS( (const bind& x) ) { // OK...
+ std::cout << x.i << std::endl; // ... and constant.
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/noncopyable_boost_local_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/noncopyable_boost_local_va.cpp 2011-05-15 19:53:00 EDT (Sun, 15 May 2011)
@@ -0,0 +1,34 @@
+
+#include <boost/config.hpp>
+#if defined(BOOST_NO_VARIADIC_MACROS) || defined(BOOST_LOCAL_CONFIG_COMPLIANT)
+#include <iostream>
+int main() {
+ std::cerr << "Error: This program requires variadic macros" << std::endl;
+ return 0;
+}
+#else
+
+//[noncopyable_boost_local_va_cpp
+#include <boost/local/function.hpp>
+#include <boost/noncopyable.hpp>
+#include <iostream>
+
+struct x_t: boost::noncopyable {
+ int i;
+ x_t(int _i): i(_i) {}
+};
+
+int main() {
+ x_t x(-1);
+
+ void BOOST_LOCAL_FUNCTION_PARAMS(const bind& x) { // OK...
+ std::cout << x.i << std::endl; // ... and constant.
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ return 0;
+}
+//]
+
+#endif
+
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