|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69819 - in sandbox/local/libs/local: doc/html/boost_local doc/qbk example
From: lorcaminiti_at_[hidden]
Date: 2011-03-10 09:24:27
Author: lcaminiti
Date: 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
New Revision: 69819
URL: http://svn.boost.org/trac/boost/changeset/69819
Log:
Added a few more examples used in the docs.
Added:
sandbox/local/libs/local/doc/html/boost_local/Implementation.html (contents, props changed)
sandbox/local/libs/local/doc/qbk/implementation.qbk (contents, props changed)
sandbox/local/libs/local/example/add_x_y_default.cpp (contents, props changed)
sandbox/local/libs/local/example/add_x_y_default_va.cpp (contents, props changed)
sandbox/local/libs/local/example/add_x_y_default_with_va.cpp (contents, props changed)
sandbox/local/libs/local/example/ten.cpp (contents, props changed)
sandbox/local/libs/local/example/ten_ep.cpp (contents, props changed)
sandbox/local/libs/local/example/ten_va.cpp (contents, props changed)
sandbox/local/libs/local/example/typeof.cpp (contents, props changed)
sandbox/local/libs/local/example/typeof_tpl.cpp (contents, props changed)
Added: sandbox/local/libs/local/doc/html/boost_local/Implementation.html
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/doc/html/boost_local/Implementation.html 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,72 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Appendix: Implementation</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Boost.Local 0.1.1">
+<link rel="up" href="../index.html" title="Boost.Local 0.1.1">
+<link rel="prev" href="Alternatives.html" title="Appendix: Alternatives">
+<link rel="next" href="Releases.html" title="Releases">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="Alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Releases.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_local.Implementation"></a><a class="link" href="Implementation.html" title="Appendix: Implementation">Appendix: Implementation</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section">Local Functions</span></dt>
+<dt><span class="section">Local Blocks</span></dt>
+<dt><span class="section">Local Exits</span></dt>
+</dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_local.Implementation.local_functions"></a><a class="link" href="Implementation.html#boost_local.Implementation.local_functions" title="Local Functions">Local Functions</a>
+</h3></div></div></div>
+<p>
+ [factorial_impl_cpp]
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_local.Implementation.local_blocks"></a><a class="link" href="Implementation.html#boost_local.Implementation.local_blocks" title="Local Blocks">Local Blocks</a>
+</h3></div></div></div>
+<p>
+ [add_block_impl_cpp]
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_local.Implementation.local_exits"></a><a class="link" href="Implementation.html#boost_local.Implementation.local_exits" title="Local Exits">Local Exits</a>
+</h3></div></div></div>
+<p>
+ [add_exit_impl_cpp]
+ </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 -2011 Lorenzo Caminiti<p>
+ Use, modification, and distribution is subject to the Boost Software License,
+ Version 1.0 (see accompanying file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="Alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Releases.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/local/libs/local/doc/qbk/implementation.qbk
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/doc/qbk/implementation.qbk 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,23 @@
+
+[section:Implementation Appendix: Implementation]
+
+[section Local Functions]
+
+[factorial_impl_cpp]
+
+[endsect]
+
+[section Local Blocks]
+
+[add_block_impl_cpp]
+
+[endsect]
+
+[section Local Exits]
+
+[add_exit_impl_cpp]
+
+[endsect]
+
+[endsect]
+
Added: sandbox/local/libs/local/example/add_x_y_default.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_x_y_default.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,20 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_x_y_default_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (int x) (int y)(default 2) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1);
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_x_y_default_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_x_y_default_va.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,20 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_x_y_default_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y, default 2) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1);
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_x_y_default_with_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_x_y_default_with_va.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,22 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_x_y_default_with_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+#define WITH_DEFAULT , default
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y WITH_DEFAULT 2) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1);
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/ten.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/ten.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,15 @@
+
+//[ten_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (void) ) {
+ return 10;
+ } BOOST_LOCAL_FUNCTION_NAME(ten)
+
+ std::cout << ten() << std::endl;
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/ten_ep.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/ten_ep.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,15 @@
+
+//[ten_ep_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS() {
+ return 10;
+ } BOOST_LOCAL_FUNCTION_NAME(ten)
+
+ std::cout << ten() << std::endl;
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/ten_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/ten_va.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,15 @@
+
+//[ten_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ int BOOST_LOCAL_FUNCTION_PARAMS(void) {
+ return 10;
+ } BOOST_LOCAL_FUNCTION_NAME(ten)
+
+ std::cout << ten() << std::endl;
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/typeof.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/typeof.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,54 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[typeof_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/block.hpp>
+#include <boost/local/exit.hpp>
+#include <boost/local/typeof.hpp> // Typeof header.
+#include <boost/type_traits.hpp>
+#include <algorithm>
+#include <cassert>
+
+double total(const double& x, const double& y, const double& z) {
+ double sum = double();
+ int factor = 10;
+
+ double BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor)
+ (bind& sum) ) {
+ BOOST_LOCAL_TYPEOF(factor) f = factor;
+ return sum += f * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+ add(x);
+
+ size_t size = 2;
+ double* nums = new double[size];
+ BOOST_LOCAL_EXIT( (const bind& size) (bind nums) ) {
+ BOOST_LOCAL_TYPEOF(size) 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( (const bind &sum) (const bind& factor)
+ (const bind& x) (const bind& y) (const bind& z) ) {
+ // Typeof qualified with eventual bind's `const` and `&`.
+ boost::remove_const<boost::remove_reference<
+ BOOST_LOCAL_TYPEOF(sum)>::type>::type s;
+ s = sum;
+ assert(s == factor * (x + y + z));
+ } BOOST_LOCAL_BLOCK_END
+
+ return sum;
+}
+
+int main() {
+ total(100.0, 90.5, 7.0);
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/typeof_tpl.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/typeof_tpl.cpp 2011-03-10 09:24:25 EST (Thu, 10 Mar 2011)
@@ -0,0 +1,55 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[typeof_template_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/block.hpp>
+#include <boost/local/exit.hpp>
+#include <boost/local/typeof.hpp> // Typeof header.
+#include <boost/type_traits.hpp>
+#include <algorithm>
+#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) ) {
+ 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) ) {
+ BOOST_LOCAL_TYPEOF(size) 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 qualified with eventual bind's `const` and `&`.
+ typename boost::remove_const<typename boost::remove_reference<
+ BOOST_LOCAL_TYPEOF(sum)>::type>::type s;
+ s = sum;
+ assert(s == factor * (x + y + z));
+ } BOOST_LOCAL_BLOCK_END
+
+ return sum;
+}
+
+int main() {
+ total(100.0, 90.5, 7.0);
+ return 0;
+}
+//]
+
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