|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71847 - sandbox/local/libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-05-09 12:55:37
Author: lcaminiti
Date: 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
New Revision: 71847
URL: http://svn.boost.org/trac/boost/changeset/71847
Log:
Removed tmp examples to test overloading.
Removed:
sandbox/local/libs/local/example/p00.cpp
sandbox/local/libs/local/example/p01.cpp
sandbox/local/libs/local/example/p02.cpp
sandbox/local/libs/local/example/p03.cpp
sandbox/local/libs/local/example/p10.cpp
sandbox/local/libs/local/example/p11.cpp
sandbox/local/libs/local/example/p12.cpp
sandbox/local/libs/local/example/p13.cpp
sandbox/local/libs/local/example/p20.cpp
sandbox/local/libs/local/example/p21.cpp
sandbox/local/libs/local/example/p21.py
sandbox/local/libs/local/example/p22.cpp
sandbox/local/libs/local/example/p30.cpp
sandbox/local/libs/local/example/p31.cpp
sandbox/local/libs/local/example/p34.cpp
Deleted: sandbox/local/libs/local/example/p00.cpp
==============================================================================
--- sandbox/local/libs/local/example/p00.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,35 +0,0 @@
-
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-struct global_add {
- global_add(double& _sum, const int& _factor): sum(_sum), factor(_factor) {}
- template<typename T>
- inline void operator()(T num) {
- std::cout << "sum = " << sum << " + " << factor << " * " << num <<
- std::endl;
- sum += factor * num;
- }
-private:
- double& sum;
- const int& factor;
-};
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- global_add add(sum, factor);
-
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), l);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), l);
-
- std::cout << sum << std::endl;
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p01.cpp
==============================================================================
--- sandbox/local/libs/local/example/p01.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,31 +0,0 @@
-
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-struct global_func {
- template<typename T>
- void operator()(T num) {
- }
-private:
- double& sum;
- const int& factor;
-};
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- global_ add(sum, factor);
-
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), l);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), l);
-
- std::cout << sum << std::endl;
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p02.cpp
==============================================================================
--- sandbox/local/libs/local/example/p02.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,28 +0,0 @@
-
-#include <boost/spirit/include/phoenix.hpp>
-#include <iostream>
-#include <vector>
-
-int main() {
- using boost::phoenix::arg_names::_1;
-
-// __some_local_template_type__ local_add =
-// let(_f = cref(factor))[ref(sum) += _f * _1];
-
-// boost::phoenix::actor<boost::phoenix::argument<1> >
-// boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::plus_assign_eval, boost::fusion::vector<boost::phoenix::reference<double>, boost::phoenix::composite<boost::phoenix::multiplies_eval, boost::fusion::vector<boost::phoenix::value<int>, boost::phoenix::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >
-
- boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::shift_left_eval, boost::fusion::vector<boost::phoenix::composite<boost::phoenix::shift_left_eval, boost::fusion::vector<boost::phoenix::reference<std::basic_ostream<char, std::char_traits<char> > >, boost::phoenix::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, boost::phoenix::value<const char*>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >
- f = std::cout << _1 << "\n";
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
- std::for_each(v.begin(), v.end(), f);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), std::cout << _1 << "\n");
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p03.cpp
==============================================================================
--- sandbox/local/libs/local/example/p03.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,22 +0,0 @@
-
-#include <boost/spirit/include/phoenix.hpp>
-#include <iostream>
-#include <vector>
-
-int main() {
- using boost::phoenix::arg_names::_1;
-
- boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::shift_left_eval, boost::fusion::vector<boost::phoenix::composite<boost::phoenix::shift_left_eval, boost::fusion::vector<boost::phoenix::reference<std::basic_ostream<char, std::char_traits<char> > >, boost::phoenix::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, boost::phoenix::value<const char*>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >
- f = std::cout << _1 << "\n";
-
- std::vector<double> v(3);
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), f);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), f);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p10.cpp
==============================================================================
--- sandbox/local/libs/local/example/p10.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,33 +0,0 @@
-
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-template<typename T>
-struct func {
- func(void *obj, void (*call)(void*, T)): obj_(obj), call_(call) {}
-
-};
-
-int main() {
- struct fctor {
- void operator()(const double& num) const { std::cout << num << std::endl; }
- void operator()(const std::string& num) const { std::cout << num << std::endl; }
- };
-
- void BOOST_LOCAL_FUNCTION_PARAMS(
- types(const double&, const std::string&) num) {
- std::cout << num << std::endl;
- }
-
- std::vector<double> v(3);
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), f);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), f);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p11.cpp
==============================================================================
--- sandbox/local/libs/local/example/p11.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,30 +0,0 @@
-
-//#include <boost/local/fuction.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <boost/preprocessor.hpp>
-
-#define BOOST_LOCAL_FUNCTION_PARAMS(params) \
- BOOST_LOCAL_FUNCTION_PARAMS_(params) BOOST_PP_LPAREN
-
-#define BOOST_LOCAL_FUNCTION_NAME(name) \
- BOOST_PP_RPAREN BOOST_LOCAL_FUNCTION_NAME_(name)
-
-int main() {
- void BOOST_LOCAL_FUNCTION_PARAMS(
- types(const double&, const std::string&) num) {
- std::cout << num << std::endl;
- } BOOST_LOCAL_FUNCTION_NAME(l)
-
- std::vector<double> v(3);
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), l);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), l);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p12.cpp
==============================================================================
--- sandbox/local/libs/local/example/p12.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,27 +0,0 @@
-
-//#include <boost/local/fuction.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <boost/preprocessor.hpp>
-
-#define P(params, body)
-
-A(bc) X(yz) --> W(bc, yz)
-
-int main() {
- void P( (types(const double&, const std::string&) num) (int x), {
- std::cout << num << std::endl;
- }) N(l)
-
- std::vector<double> v(3);
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), l);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), l);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p13.cpp
==============================================================================
--- sandbox/local/libs/local/example/p13.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,75 +0,0 @@
-
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-template<typename T1 = void, typename T2 = void, typename T3 = void>
-struct types {};
-
-template<typename F>
-struct func {};
-
-template<typename R, typename A1>
-struct func<R (A1)> {
- typedef R (*call_ptr)(void*, A1);
- func(void* obj, call_ptr call): obj_(obj), call_(call) {}
- R operator()(A1 a1) { return call_(obj_, a1); }
-private:
- void* obj_;
- call_ptr call_;
-};
-
-template<typename R, typename A1T1, typename A1T2>
-struct func<R (types<A1T1, A1T2>)> {
- typedef R (*call_a1t1_ptr)(void*, A1T1);
- typedef R (*call_a1t2_ptr)(void*, A1T2);
- func(void* obj, call_a1t1_ptr call_a1t1, call_a1t2_ptr call_a1t2):
- obj_(obj), call_a1t1_(call_a1t1), call_a1t2_(call_a1t2) {}
- R operator()(A1T1 a1t1) { return call_a1t1_(obj_, a1t1); }
- R operator()(A1T2 a1t2) { return call_a1t2_(obj_, a1t2); }
-private:
- void* obj_;
- call_a1t1_ptr call_a1t1_;
- call_a1t2_ptr call_a1t2_;
-};
-
-int main() {
-// void BOOST_LOCAL_FUNCTION(types(const double&, const std::string&) num,
-// const bind& sep, {
-// std::cout << num << std::endl;
-// }) BOOST_LOCAL_FUNCTION_NAME(l)
-
- char sep = '\n';
-
- struct local {
- local(const char& sep): sep_(sep) {}
- void operator()(double num) { body(sep_, num); }
- static void call(void* obj, double num)
- { (*static_cast<local*>(obj))(num); }
-
- void operator()(std::string num) { body(sep_, num); }
- static void call(void* obj, std::string num)
- { (*static_cast<local*>(obj))(num); }
- private:
- const char& sep_;
- void body(const char& sep, double num)
- { std::cout << num << std::endl; }
- void body(const char& sep, std::string num)
- { std::cout << num << std::endl; }
- } local_l(sep);
- func<void (types<double, std::string>)> l(&local_l,
- local_l.call, local_l.call);
-
- std::vector<double> v(3);
- v[0] = -1.0; v[1] = -2.0; v[2] = -3.0;
- std::for_each(v.begin(), v.end(), l);
- l(0);
-
- std::vector<std::string> s(3);
- s[0] = "aa"; s[1] = "bb"; s[2] = "cc";
- std::for_each(s.begin(), s.end(), l);
- l("zz");
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p20.cpp
==============================================================================
--- sandbox/local/libs/local/example/p20.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,57 +0,0 @@
-
-#include <string>
-
-std::string A(size_t arity, size_t type) {
- return std::string("A") +
-}
-
-R operator()(A1T1);
-R operator()(A1T2);
-R operator()(A1T3);
-
-R operator()(A1T1, A2T1);
-R operator()(A1T1, A2T2);
-R operator()(A1T1, A2T3);
-//
-R operator()(A1T2, A2T1);
-R operator()(A1T2, A2T2);
-R operator()(A1T2, A2T3);
-//
-R operator()(A1T3, A2T1);
-R operator()(A1T3, A2T2);
-R operator()(A1T3, A2T3);
-
-template<R, typename A0T0, typename A0T1, typename A1T0, typename A1T1, typename A2T0> {
-} class function<
- R (types<A0T0, A0T1>, types<A1T0, A1T1>, A2T0), 1
-> {
- typedef void* object_ptr;
- typedef R (*call_ptr)(object_ptr
- , typename ::boost::call_tratis<A0T0>::param_type
- , typename ::boost::call_tratis<A1T0>::param_type
- , typename ::boost::call_tratis<A2T0>::param_type);
- typedef R (*call_ptr)(object_ptr
- , typename ::boost::call_tratis<A0T1>::param_type
- , typename ::boost::call_tratis<A1T0>::param_type
- , typename ::boost::call_tratis<A2T0>::param_type);
-};
-
-
-int main() {
- size_t arity = 5;
- size_t types = 3;
- size_t defaults = 0;
-
- for (a = 0; a < arity; ++a) {
- for (t = 0; t < types; ++t) {
- for (d = 0; d < defaults; ++d) {
- std::cout <<
-"R operator()(A)
-
- }
- }
- }
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p21.cpp
==============================================================================
--- sandbox/local/libs/local/example/p21.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,16 +0,0 @@
-
-#include <boost/preprocessor.hpp>
-
-for t in range(types):
- for u in range(types):
- for v in range(types):
- print t, u, v, w
-
-#define Y(z, n, u) \
-
-#define X(z, n, u) \
- BOOST_PP_REPEAT_ ## a(2, Y, ~)
-
-BOOST_PP_REPEAT(2, X, ~)
-
-
Deleted: sandbox/local/libs/local/example/p21.py
==============================================================================
--- sandbox/local/libs/local/example/p21.py 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,28 +0,0 @@
-
-import itertools
-
-def AT(n, t): return "A" + str(n) + "T" + str(t)
-
-arity = 3
-types = 2
-
-l = []
-for n in range(0, arity):
- for t in range(0, types):
- l.append(AT(n, t))
-
-print l
-for s in itertools.combinations(l, 3):
- print s
-
-for t in range(types):
- for u in range(types):
- for v in range(types):
- for w in range(types):
- print t, u, v, w
-
-print
-
-for i in range(arity):
- print i
-
Deleted: sandbox/local/libs/local/example/p22.cpp
==============================================================================
--- sandbox/local/libs/local/example/p22.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,5 +0,0 @@
-
-#include <boost/preprocessor.hpp>
-
-BOOST_PP_REPEAT_FROM_TO(0, 3, X
-
Deleted: sandbox/local/libs/local/example/p30.cpp
==============================================================================
--- sandbox/local/libs/local/example/p30.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,50 +0,0 @@
-
-#include <boost/local/function.hpp>
-#include <boost/function.hpp>
-#include <vector>
-#include <algorithm>
-#include <iostream>
-#include <string>
-
-template<typename F0, typename F1, typename F2 = void, typename F3 = void>
-struct overload {
-};
-
-template<typename F0R, typename F0A0, typename F1R, typename F1A0>
-struct overload<F0R (F0A0), F1R (F1A0)> {
- overload(boost::function<F0R (F0A0)> f0, boost::function<F1R (F1A0)> f1):
- f0_(f0), f1_(f1) {}
- F0R operator()(F0A0 a0) const { return f0_(a0); }
- F1R operator()(F1A0 a0) const { return f1_(a0); }
-private:
- boost::function<F0R (F0A0)> f0_;
- boost::function<F1R (F1A0)> f1_;
-};
-
-// More specializations to overload also with F2, F3, etc.
-
-int main() {
- char sep = '\n';
-
- void BOOST_LOCAL_FUNCTION_PARAMS(const double& num, const bind& sep) {
- std::cout << num << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_d)
-
- void BOOST_LOCAL_FUNCTION_PARAMS(const std::string& num, const bind& sep) {
- std::cout << num << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_s)
-
- overload<void (const double&), void (const std::string&)> print(
- print_d, print_s);
-
- std::vector<double> d(2);
- d[0] = 1.2; d[1] = 3.4;
- std::for_each(d.begin(), d.end(), print);
-
- std::vector<std::string> s(3);
- s[0] = "ab"; s[1] = "cd"; s[2] = "ef";
- std::for_each(s.begin(), s.end(), print);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p31.cpp
==============================================================================
--- sandbox/local/libs/local/example/p31.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,47 +0,0 @@
-
-#include <boost/local/function.hpp>
-#include <boost/function.hpp>
-#include <vector>
-#include <algorithm>
-#include <iostream>
-#include <string>
-
-template<typename F, typename G>
-struct overloader {
- overloader(F f, G g): f_(f), g_(g) {}
- template<typename A0>
- void operator()(A0 a0) const { return f_(a0); }
- template<typename A0>
- void operator()(A0 a0) const { return g_(a0); }
-private:
- F f_;
- G g_;
-};
-
-template<typename F, typename G>
-overloader<F, G> overload(F f, G g) { return overloader<F, G>(f, g); }
-
-int main() {
- char sep = '\n';
- void BOOST_LOCAL_FUNCTION_PARAMS(const double& num, const bind& sep) {
- std::cout << num << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_d)
- void BOOST_LOCAL_FUNCTION_PARAMS(const std::string& num, const bind& sep) {
- std::cout << num << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_s)
-// overloader<void (const double&), void (const std::string&)> print_ds(
-// print_d, print_s);
- __typeof__(overload(print_d, print_s)) print = overload(print_d, print_s);
-
-
- std::vector<double> d(2);
- d[0] = 1.2; d[1] = 3.4;
- std::for_each(d.begin(), d.end(), print);
-
- std::vector<std::string> s(3);
- s[0] = "ab"; s[1] = "cd"; s[2] = "ef";
- std::for_each(s.begin(), s.end(), print);
-
- return 0;
-}
-
Deleted: sandbox/local/libs/local/example/p34.cpp
==============================================================================
--- sandbox/local/libs/local/example/p34.cpp 2011-05-09 12:55:35 EDT (Mon, 09 May 2011)
+++ (empty file)
@@ -1,70 +0,0 @@
-
-#include <boost/local/function.hpp>
-#include <boost/function.hpp>
-#include <vector>
-#include <algorithm>
-#include <iostream>
-#include <string>
-
-namespace boost { namespace local { namespace function {
-
-template<typename F0, typename F1, typename F2 = void, typename F3 = void>
-struct overloaded {};
-
-// Specialization for 2 functions.
-
-template<typename F0, typename F1>
-struct overloaded<F0, F1>: F0, F1 {
- overloaded(F0 const& f0, F1 const& f1):
- F0(f0), F1(f1) {}
- using F0::operator(); using F1::operator();
-};
-
-template<typename F0, typename F1>
-overloaded<F0, F1> overload(F0 const& f0, F1 const& f1) {
- return overloaded< F0, F1 >(f0, f1);
-}
-
-template<typename F0, typename F1>
-overloaded< boost::function<F0>, boost::function<F1> >
-overload(
- boost::local::aux::function<F0> const& f0
- , boost::local::aux::function<F1> const& f1
-) {
- return overloaded< boost::function<F0>, boost::function<F1> >(f0, f1);
-}
-
-}}} // namespace boost::local::function
-
-// More specializations to overload also with F2, F3, etc.
-
-int main() {
- char sep = '\n';
-
- void BOOST_LOCAL_FUNCTION_PARAMS(const double& item, int x, default 1, const bind& sep) {
- std::cout << item << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_double)
-
- void BOOST_LOCAL_FUNCTION_PARAMS(const std::string& item, const bind& sep) {
- std::cout << item << sep;
- } BOOST_LOCAL_FUNCTION_NAME(print_string)
-
- boost::local::function::overloaded<
- boost::function< void (const double&) >
- , boost::function< void (const std::string&) >
- > print = boost::local::function::overload(
- boost::function< void (const double&) >(print_double)
- , boost::function< void (const std::string&) >(print_string)
- );
-
- std::vector<double> d(2);
- d[0] = 1.2; d[1] = 3.4;
- std::for_each(d.begin(), d.end(), print);
-
- std::vector<std::string> s(3);
- s[0] = "ab"; s[1] = "cd"; s[2] = "ef";
- std::for_each(s.begin(), s.end(), print);
-
- 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