benchcc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.gitmodules +6 -0
  4. data/Gemfile +13 -0
  5. data/LICENSE.md +25 -0
  6. data/README.md +3 -0
  7. data/Rakefile +11 -0
  8. data/benchcc.gemspec +24 -0
  9. data/benchmarks/Rakefile +78 -0
  10. data/benchmarks/fmap/_env.rb +3 -0
  11. data/benchmarks/fmap/_main.erb +7 -0
  12. data/benchmarks/fmap/hana_list.erb.cpp +18 -0
  13. data/benchmarks/fmap/mpl11_list.erb.cpp +15 -0
  14. data/benchmarks/fmap/mpl_list.erb.cpp +15 -0
  15. data/benchmarks/fmap/mpl_vector.erb.cpp +15 -0
  16. data/benchmarks/include/_env.rb +1 -0
  17. data/benchmarks/include/hana.erb.cpp +1 -0
  18. data/benchmarks/include/mpl.erb.cpp +185 -0
  19. data/benchmarks/include/mpl11.erb.cpp +1 -0
  20. data/benchmarks/include/mpl11.min.erb.cpp +1 -0
  21. data/benchmarks/sum/_env.rb +3 -0
  22. data/benchmarks/sum/_main.erb +4 -0
  23. data/benchmarks/sum/constexpr.erb.cpp +24 -0
  24. data/benchmarks/sum/mpl11_variadic_foldl.erb.cpp +16 -0
  25. data/benchmarks/tuple_create/_env.rb +3 -0
  26. data/benchmarks/tuple_create/boost_tuple.erb.cpp +6 -0
  27. data/benchmarks/tuple_create/fusion_tuple.erb.cpp +6 -0
  28. data/benchmarks/tuple_create/hana_list.erb.cpp +6 -0
  29. data/benchmarks/tuple_create/std_tuple.erb.cpp +6 -0
  30. data/benchmarks/tuple_last/_env.rb +3 -0
  31. data/benchmarks/tuple_last/boost_tuple.erb.cpp +7 -0
  32. data/benchmarks/tuple_last/fusion_tuple.erb.cpp +7 -0
  33. data/benchmarks/tuple_last/hana_list.erb.cpp +7 -0
  34. data/benchmarks/tuple_last/std_tuple.erb.cpp +7 -0
  35. data/benchmarks/type_foldl/_env.rb +3 -0
  36. data/benchmarks/type_foldl/_main.erb +18 -0
  37. data/benchmarks/type_foldl/hana_list.erb.cpp +15 -0
  38. data/benchmarks/type_foldl/mpl11_cons.erb.cpp +10 -0
  39. data/benchmarks/type_foldl/mpl11_list.erb.cpp +8 -0
  40. data/benchmarks/type_foldl/mpl_list.erb.cpp +7 -0
  41. data/benchmarks/type_foldl/mpl_vector.erb.cpp +7 -0
  42. data/benchmarks/value_foldl/_env.rb +3 -0
  43. data/benchmarks/value_foldl/_main.erb +17 -0
  44. data/benchmarks/value_foldl/fusion_cons.erb.cpp +8 -0
  45. data/benchmarks/value_foldl/fusion_list.erb.cpp +9 -0
  46. data/benchmarks/value_foldl/fusion_vector.erb.cpp +9 -0
  47. data/benchmarks/value_foldl/hana_list.erb.cpp +6 -0
  48. data/lib/benchcc/benchmark.rb +53 -0
  49. data/lib/benchcc/compiler.rb +134 -0
  50. data/lib/benchcc/ext/enumerable.rb +7 -0
  51. data/lib/benchcc/ext/file.rb +16 -0
  52. data/lib/benchcc/ext/gnuplot.rb +8 -0
  53. data/lib/benchcc/ext/numeric.rb +15 -0
  54. data/lib/benchcc/ext/string.rb +5 -0
  55. data/lib/benchcc/fusion.rb +54 -0
  56. data/lib/benchcc/mpl.rb +48 -0
  57. data/lib/benchcc/plot.rb +44 -0
  58. data/lib/benchcc/version.rb +3 -0
  59. data/lib/benchcc.rb +6 -0
  60. data/spec/benchmark_spec.rb +23 -0
  61. data/spec/compiler_spec.rb +69 -0
  62. data/spec/numeric_spec.rb +23 -0
  63. data/spec/plot_spec.rb +29 -0
  64. data/spec/src/invalid.cpp +1 -0
  65. data/spec/src/plot.csv +3 -0
  66. data/spec/src/valid.cpp +1 -0
  67. metadata +166 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c435cda71ad508017a69a33b232ef6a7ed334df8
4
+ data.tar.gz: c2c9a7bd9355414ea1388f7e792b630a3a0b79c8
5
+ SHA512:
6
+ metadata.gz: da5d488a8e4cdb1984cb174c6b622dcba891d588bd734c9421f02dd6c412d1c243b307b09b0f4c3fba7476342a9acbfb520818abdbe80714dbebac666e9a4812
7
+ data.tar.gz: c5ab9643575c8d740e5521e8ed8ad04d78751488a30773b951a4bdb57a0fbf1319d75c4e3d3c4b6734f67647b2f394abd1ec9716907b9ebe3081479dc67a48aa
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ _datasets/
data/.gitmodules ADDED
@@ -0,0 +1,6 @@
1
+ [submodule "ext/boost.mpl11"]
2
+ path = ext/boost.mpl11
3
+ url = https://github.com/ldionne/mpl11.git
4
+ [submodule "ext/boost.hana"]
5
+ path = ext/boost.hana
6
+ url = https://github.com/ldionne/hana.git
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'bundler', '~> 1.3'
4
+
5
+ group :development do
6
+ gem 'pry'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rspec', '>= 2.14'
11
+ end
12
+
13
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,25 @@
1
+ Copyright 2014 Louis Dionne
2
+
3
+ Boost Software License - Version 1.0 - August 17th, 2003
4
+
5
+ Permission is hereby granted, free of charge, to any person or organization
6
+ obtaining a copy of the software and accompanying documentation covered by
7
+ this license (the "Software") to use, reproduce, display, distribute,
8
+ execute, and transmit the Software, and to prepare derivative works of the
9
+ Software, and to permit third-parties to whom the Software is furnished to
10
+ do so, all subject to the following:
11
+
12
+ The copyright notices in the Software and this entire statement, including
13
+ the above license grant, this restriction and the following disclaimer,
14
+ must be included in all copies of the Software, in whole or in part, and
15
+ all derivative works of the Software, unless such copies or derivative
16
+ works are solely in the form of machine-executable object code generated by
17
+ a source language processor.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
+ DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # benchcc
2
+
3
+ > A collection of C++ metaprogramming benchmarks
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
+ require "rake"
4
+ require "rspec/core/rake_task"
5
+
6
+ task default: :spec
7
+
8
+ desc "Run all specs"
9
+ RSpec::Core::RakeTask.new(:spec) do |task|
10
+ task.pattern = 'spec/**/*_spec.rb'
11
+ end
data/benchcc.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ $:.unshift File.expand_path('../lib', __FILE__)
4
+ require 'benchcc/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "benchcc"
8
+ s.version = Benchcc::VERSION
9
+ s.authors = ["Louis Dionne"]
10
+ s.email = ["ldionne.2@gmail.com"]
11
+ s.homepage = "https://github.com/ldionne/benchcc"
12
+ s.license = "Boost"
13
+ s.summary = "A collection of utilities to benchmark C++ metaprograms"
14
+ s.description = "Benchcc is a collection of utilities to make easier the task of benchmarking C++ metaprograms"
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.platform = Gem::Platform::RUBY
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency 'gnuplot', "~> 2.6"
21
+ s.add_dependency 'rake', "~> 10.2"
22
+ s.add_dependency 'ruby-progressbar', "~> 1.4"
23
+ s.add_dependency 'tilt', '~> 2.0.1'
24
+ end
@@ -0,0 +1,78 @@
1
+ $:.unshift(File.expand_path('../../lib', __FILE__))
2
+
3
+ require 'benchcc'
4
+ require 'csv'
5
+ require 'gnuplot'
6
+
7
+
8
+ task :default => [:all]
9
+ task :all
10
+
11
+ INCLUDES = %w{boost.hana/include boost.mpl11/include}.map { |path|
12
+ "-I " + File.expand_path("../../ext/#{path}", __FILE__)
13
+ }
14
+
15
+
16
+ Benchcc::Compiler.list.product(Dir['*']) do |compiler, dir|
17
+ benchmark = File.basename(dir)
18
+ bm = Benchcc::Benchmark.new(benchmark)
19
+ bm.implementations.each do |implementation|
20
+ task :all => benchmark
21
+ task compiler.id => "#{compiler.id}.#{benchmark}"
22
+ task benchmark => "#{compiler.id}.#{benchmark}"
23
+ task "#{compiler.id}.#{benchmark}" => "#{compiler.id}.#{benchmark}.#{implementation}"
24
+ task "#{compiler.id}.#{benchmark}.#{implementation}" => "_datasets/#{compiler.id}/#{benchmark}/#{implementation}"
25
+
26
+ file "_datasets/#{compiler.id}/#{benchmark}/#{implementation}" => [
27
+ bm.dependencies_of(implementation),
28
+ directory("_datasets/#{compiler.id}/#{benchmark}").name
29
+ ].flatten do |ofile|
30
+ data = bm.run(implementation) { |code|
31
+ compiler.compile_code(code, *INCLUDES, "-fsyntax-only")
32
+ }
33
+
34
+ CSV.open(ofile.name, 'wb') do |csv|
35
+ csv << data.first.keys unless data.empty?
36
+ data.each { |line| csv << line.values }
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ task :memusg do |t, args|
44
+ Gnuplot.open do |io|
45
+ Gnuplot::Plot.new(io) do |plot|
46
+ plot.ylabel 'Memory usage'
47
+ plot.decimal "locale 'en_US.UTF-8'"
48
+ plot.format 'y "%.2e kb"'
49
+ plot.term 'png'
50
+ plot.output 'memusg.png'
51
+ plot.data = args.extras.map { |arg|
52
+ csv = CSV.table("_datasets/#{arg}")
53
+ Gnuplot::DataSet.new([csv[:depth], csv[:peak_memusg]]) { |ds|
54
+ ds.title = arg
55
+ ds.with = 'lines'
56
+ }
57
+ }
58
+ end
59
+ end
60
+ end
61
+
62
+ task :time do |t, args|
63
+ Gnuplot.open do |io|
64
+ Gnuplot::Plot.new(io) do |plot|
65
+ plot.ylabel 'Compilation time'
66
+ plot.format 'y "%.2g s"'
67
+ plot.term 'png'
68
+ plot.output 'time.png'
69
+ plot.data = args.extras.map { |arg|
70
+ csv = CSV.table("_datasets/#{arg}")
71
+ Gnuplot::DataSet.new([csv[:depth], csv[:wall_time]]) { |ds|
72
+ ds.title = arg
73
+ ds.with = 'lines'
74
+ }
75
+ }
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ (0...1000).map { |depth|
2
+ { breadth: 1, depth: depth }
3
+ }
@@ -0,0 +1,7 @@
1
+ <%= (0...breadth).map { |breadth|
2
+ xs = (0...depth).map { |depth| "x#{breadth}<#{depth}>" }
3
+ <<-EOS
4
+ template <int> struct x#{breadth} { using type = x#{breadth}; };
5
+ #{yield xs, breadth, depth}
6
+ EOS
7
+ }.join("\n") %>
@@ -0,0 +1,18 @@
1
+ #include <boost/hana/list.hpp>
2
+
3
+
4
+ template <typename X>
5
+ struct _f { };
6
+
7
+ constexpr struct {
8
+ template <typename X>
9
+ constexpr _f<X> operator()(X) const;
10
+ } f{};
11
+
12
+ <%=
13
+ render('_main.erb') do |xs, breadth, depth|
14
+ xs = xs.map { |x| "#{x}{}" }.join(', ')
15
+ list = "boost::hana::list(#{xs})"
16
+ "static const auto go#{breadth} = boost::hana::fmap(f, #{list});"
17
+ end
18
+ %>
@@ -0,0 +1,15 @@
1
+ #include <boost/mpl11/list.hpp>
2
+
3
+
4
+ struct f {
5
+ using type = f;
6
+ template <typename>
7
+ struct apply { struct type; };
8
+ };
9
+
10
+ <%=
11
+ render('_main.erb') do |xs, breadth, depth|
12
+ list = "boost::mpl11::list<#{xs.join(', ')}>"
13
+ "using go#{breadth} = boost::mpl11::fmap<f, #{list}>::type;"
14
+ end
15
+ %>
@@ -0,0 +1,15 @@
1
+ #include <boost/mpl/transform.hpp>
2
+ <%= Benchcc::MPL::List.new(0...depth).includes %>
3
+
4
+
5
+ struct f {
6
+ template <typename>
7
+ struct apply { struct type; };
8
+ };
9
+
10
+ <%=
11
+ render('_main.erb') do |xs, breadth, depth|
12
+ list = Benchcc::MPL::List.new(xs)
13
+ "using go#{breadth} = boost::mpl::transform<#{list}, f>::type;"
14
+ end
15
+ %>
@@ -0,0 +1,15 @@
1
+ #include <boost/mpl/transform.hpp>
2
+ <%= Benchcc::MPL::Vector.new(0...depth).includes %>
3
+
4
+
5
+ struct f {
6
+ template <typename>
7
+ struct apply { struct type; };
8
+ };
9
+
10
+ <%=
11
+ render('_main.erb') do |xs, breadth, depth|
12
+ vector = Benchcc::MPL::Vector.new(xs)
13
+ "using go#{breadth} = boost::mpl::transform<#{vector}, f>::type;"
14
+ end
15
+ %>
@@ -0,0 +1 @@
1
+ 1.times.map { Hash.new }
@@ -0,0 +1 @@
1
+ #include <boost/hana.hpp>
@@ -0,0 +1,185 @@
1
+ #include <boost/mpl/accumulate.hpp>
2
+ #include <boost/mpl/advance.hpp>
3
+ #include <boost/mpl/advance_fwd.hpp>
4
+ #include <boost/mpl/alias.hpp>
5
+ #include <boost/mpl/always.hpp>
6
+ #include <boost/mpl/and.hpp>
7
+ #include <boost/mpl/apply.hpp>
8
+ #include <boost/mpl/apply_fwd.hpp>
9
+ #include <boost/mpl/apply_wrap.hpp>
10
+ #include <boost/mpl/arg.hpp>
11
+ #include <boost/mpl/arg_fwd.hpp>
12
+ #include <boost/mpl/arithmetic.hpp>
13
+ #include <boost/mpl/as_sequence.hpp>
14
+ #include <boost/mpl/assert.hpp>
15
+ #include <boost/mpl/at.hpp>
16
+ #include <boost/mpl/at_fwd.hpp>
17
+ #include <boost/mpl/back.hpp>
18
+ #include <boost/mpl/back_fwd.hpp>
19
+ #include <boost/mpl/back_inserter.hpp>
20
+ #include <boost/mpl/base.hpp>
21
+ #include <boost/mpl/begin.hpp>
22
+ #include <boost/mpl/begin_end.hpp>
23
+ #include <boost/mpl/begin_end_fwd.hpp>
24
+ #include <boost/mpl/bind.hpp>
25
+ #include <boost/mpl/bind_fwd.hpp>
26
+ #include <boost/mpl/bitand.hpp>
27
+ #include <boost/mpl/bitor.hpp>
28
+ #include <boost/mpl/bitwise.hpp>
29
+ #include <boost/mpl/bitxor.hpp>
30
+ #include <boost/mpl/bool.hpp>
31
+ #include <boost/mpl/bool_fwd.hpp>
32
+ #include <boost/mpl/char.hpp>
33
+ #include <boost/mpl/char_fwd.hpp>
34
+ #include <boost/mpl/clear.hpp>
35
+ #include <boost/mpl/clear_fwd.hpp>
36
+ #include <boost/mpl/comparison.hpp>
37
+ #include <boost/mpl/contains.hpp>
38
+ #include <boost/mpl/contains_fwd.hpp>
39
+ #include <boost/mpl/copy.hpp>
40
+ #include <boost/mpl/copy_if.hpp>
41
+ #include <boost/mpl/count.hpp>
42
+ #include <boost/mpl/count_fwd.hpp>
43
+ #include <boost/mpl/count_if.hpp>
44
+ #include <boost/mpl/deque.hpp>
45
+ #include <boost/mpl/deref.hpp>
46
+ #include <boost/mpl/distance.hpp>
47
+ #include <boost/mpl/distance_fwd.hpp>
48
+ #include <boost/mpl/divides.hpp>
49
+ #include <boost/mpl/empty.hpp>
50
+ #include <boost/mpl/empty_base.hpp>
51
+ #include <boost/mpl/empty_fwd.hpp>
52
+ #include <boost/mpl/empty_sequence.hpp>
53
+ #include <boost/mpl/end.hpp>
54
+ #include <boost/mpl/equal.hpp>
55
+ #include <boost/mpl/equal_to.hpp>
56
+ #include <boost/mpl/erase.hpp>
57
+ #include <boost/mpl/erase_fwd.hpp>
58
+ #include <boost/mpl/erase_key.hpp>
59
+ #include <boost/mpl/erase_key_fwd.hpp>
60
+ #include <boost/mpl/eval_if.hpp>
61
+ #include <boost/mpl/filter_view.hpp>
62
+ #include <boost/mpl/find.hpp>
63
+ #include <boost/mpl/find_if.hpp>
64
+ #include <boost/mpl/fold.hpp>
65
+ #include <boost/mpl/for_each.hpp>
66
+ #include <boost/mpl/front.hpp>
67
+ #include <boost/mpl/front_fwd.hpp>
68
+ #include <boost/mpl/front_inserter.hpp>
69
+ #include <boost/mpl/greater.hpp>
70
+ #include <boost/mpl/greater_equal.hpp>
71
+ #include <boost/mpl/has_key.hpp>
72
+ #include <boost/mpl/has_key_fwd.hpp>
73
+ #include <boost/mpl/has_xxx.hpp>
74
+ #include <boost/mpl/identity.hpp>
75
+ #include <boost/mpl/if.hpp>
76
+ #include <boost/mpl/index_if.hpp>
77
+ #include <boost/mpl/index_of.hpp>
78
+ #include <boost/mpl/inherit.hpp>
79
+ #include <boost/mpl/inherit_linearly.hpp>
80
+ #include <boost/mpl/insert.hpp>
81
+ #include <boost/mpl/insert_fwd.hpp>
82
+ #include <boost/mpl/insert_range.hpp>
83
+ #include <boost/mpl/insert_range_fwd.hpp>
84
+ #include <boost/mpl/inserter.hpp>
85
+ #include <boost/mpl/int.hpp>
86
+ #include <boost/mpl/int_fwd.hpp>
87
+ #include <boost/mpl/integral_c.hpp>
88
+ #include <boost/mpl/integral_c_fwd.hpp>
89
+ #include <boost/mpl/integral_c_tag.hpp>
90
+ #include <boost/mpl/is_placeholder.hpp>
91
+ #include <boost/mpl/is_sequence.hpp>
92
+ #include <boost/mpl/iter_fold.hpp>
93
+ #include <boost/mpl/iter_fold_if.hpp>
94
+ #include <boost/mpl/iterator_category.hpp>
95
+ #include <boost/mpl/iterator_range.hpp>
96
+ #include <boost/mpl/iterator_tags.hpp>
97
+ #include <boost/mpl/joint_view.hpp>
98
+ #include <boost/mpl/key_type.hpp>
99
+ #include <boost/mpl/key_type_fwd.hpp>
100
+ #include <boost/mpl/lambda.hpp>
101
+ #include <boost/mpl/lambda_fwd.hpp>
102
+ #include <boost/mpl/less.hpp>
103
+ #include <boost/mpl/less_equal.hpp>
104
+ #include <boost/mpl/list.hpp>
105
+ #include <boost/mpl/list_c.hpp>
106
+ #include <boost/mpl/logical.hpp>
107
+ #include <boost/mpl/long.hpp>
108
+ #include <boost/mpl/long_fwd.hpp>
109
+ #include <boost/mpl/lower_bound.hpp>
110
+ #include <boost/mpl/map.hpp>
111
+ #include <boost/mpl/max.hpp>
112
+ #include <boost/mpl/max_element.hpp>
113
+ #include <boost/mpl/min.hpp>
114
+ #include <boost/mpl/min_element.hpp>
115
+ #include <boost/mpl/min_max.hpp>
116
+ #include <boost/mpl/minus.hpp>
117
+ #include <boost/mpl/modulus.hpp>
118
+ #include <boost/mpl/multiplies.hpp>
119
+ #include <boost/mpl/negate.hpp>
120
+ #include <boost/mpl/next.hpp>
121
+ #include <boost/mpl/next_prior.hpp>
122
+ #include <boost/mpl/not.hpp>
123
+ #include <boost/mpl/not_equal_to.hpp>
124
+ #include <boost/mpl/numeric_cast.hpp>
125
+ #include <boost/mpl/O1_size.hpp>
126
+ #include <boost/mpl/O1_size_fwd.hpp>
127
+ #include <boost/mpl/or.hpp>
128
+ #include <boost/mpl/order.hpp>
129
+ #include <boost/mpl/order_fwd.hpp>
130
+ #include <boost/mpl/pair.hpp>
131
+ #include <boost/mpl/pair_view.hpp>
132
+ #include <boost/mpl/partition.hpp>
133
+ #include <boost/mpl/placeholders.hpp>
134
+ #include <boost/mpl/plus.hpp>
135
+ #include <boost/mpl/pop_back.hpp>
136
+ #include <boost/mpl/pop_back_fwd.hpp>
137
+ #include <boost/mpl/pop_front.hpp>
138
+ #include <boost/mpl/pop_front_fwd.hpp>
139
+ #include <boost/mpl/print.hpp>
140
+ #include <boost/mpl/prior.hpp>
141
+ #include <boost/mpl/protect.hpp>
142
+ #include <boost/mpl/push_back.hpp>
143
+ #include <boost/mpl/push_back_fwd.hpp>
144
+ #include <boost/mpl/push_front.hpp>
145
+ #include <boost/mpl/push_front_fwd.hpp>
146
+ #include <boost/mpl/quote.hpp>
147
+ #include <boost/mpl/range_c.hpp>
148
+ #include <boost/mpl/remove.hpp>
149
+ #include <boost/mpl/remove_if.hpp>
150
+ #include <boost/mpl/replace.hpp>
151
+ #include <boost/mpl/replace_if.hpp>
152
+ #include <boost/mpl/reverse.hpp>
153
+ #include <boost/mpl/reverse_fold.hpp>
154
+ #include <boost/mpl/reverse_iter_fold.hpp>
155
+ #include <boost/mpl/same_as.hpp>
156
+ #include <boost/mpl/sequence_tag.hpp>
157
+ #include <boost/mpl/sequence_tag_fwd.hpp>
158
+ #include <boost/mpl/set.hpp>
159
+ #include <boost/mpl/set_c.hpp>
160
+ #include <boost/mpl/shift_left.hpp>
161
+ #include <boost/mpl/shift_right.hpp>
162
+ #include <boost/mpl/single_view.hpp>
163
+ #include <boost/mpl/size.hpp>
164
+ #include <boost/mpl/size_fwd.hpp>
165
+ #include <boost/mpl/size_t.hpp>
166
+ #include <boost/mpl/size_t_fwd.hpp>
167
+ #include <boost/mpl/sizeof.hpp>
168
+ #include <boost/mpl/sort.hpp>
169
+ #include <boost/mpl/stable_partition.hpp>
170
+ #include <boost/mpl/string.hpp>
171
+ #include <boost/mpl/switch.hpp>
172
+ #include <boost/mpl/tag.hpp>
173
+ #include <boost/mpl/times.hpp>
174
+ #include <boost/mpl/transform.hpp>
175
+ #include <boost/mpl/transform_view.hpp>
176
+ #include <boost/mpl/unique.hpp>
177
+ #include <boost/mpl/unpack_args.hpp>
178
+ #include <boost/mpl/upper_bound.hpp>
179
+ #include <boost/mpl/value_type.hpp>
180
+ #include <boost/mpl/value_type_fwd.hpp>
181
+ #include <boost/mpl/vector.hpp>
182
+ #include <boost/mpl/vector_c.hpp>
183
+ #include <boost/mpl/void.hpp>
184
+ #include <boost/mpl/void_fwd.hpp>
185
+ #include <boost/mpl/zip_view.hpp>
@@ -0,0 +1 @@
1
+ #include <boost/mpl11.hpp>
@@ -0,0 +1 @@
1
+ #include <boost/mpl11.min.hpp>
@@ -0,0 +1,3 @@
1
+ (0...1000).map { |depth|
2
+ { breadth: 1, depth: depth }
3
+ }
@@ -0,0 +1,4 @@
1
+ <%= (0...breadth).map { |breadth|
2
+ xs = (0...depth).map { |n| "boost::mpl11::int_<#{n}>" }.join(', ')
3
+ "using go#{breadth} = sum<#{xs}>::type;"
4
+ }.join("\n") %>
@@ -0,0 +1,24 @@
1
+ #include <boost/mpl11/integer.hpp>
2
+
3
+
4
+ using size_t = decltype(sizeof(int));
5
+
6
+ constexpr struct plus_ {
7
+ template <typename X, typename Y>
8
+ constexpr auto operator()(X x, Y y) { return x + y; }
9
+ } plus{};
10
+
11
+ template <typename T, size_t N, typename F, typename State>
12
+ constexpr State homogeneous_foldl(F f, State s, const T (&array)[N]) {
13
+ for (size_t i = 0; i < N; ++i)
14
+ s = f(s, array[i]);
15
+ return s;
16
+ }
17
+
18
+ template <typename ...xs>
19
+ using sum = boost::mpl11::integer_c<
20
+ decltype(homogeneous_foldl<size_t, sizeof...(xs)>(plus, 0, {xs::value...})),
21
+ homogeneous_foldl<size_t, sizeof...(xs)>(plus, 0, {xs::value...})
22
+ >;
23
+
24
+ <%= render('_main.erb') %>
@@ -0,0 +1,16 @@
1
+ #include <boost/mpl11/detail/left_folds/variadic.hpp>
2
+ #include <boost/mpl11/integer.hpp>
3
+
4
+
5
+ template <typename x, typename y>
6
+ using plus = boost::mpl11::integer_c<
7
+ decltype(x::type::value + y::type::value),
8
+ x::type::value + y::type::value
9
+ >;
10
+
11
+ template <typename ...xs>
12
+ using sum = boost::mpl11::detail::left_folds::variadic<
13
+ plus, boost::mpl11::int_<0>, xs...
14
+ >;
15
+
16
+ <%= render('_main.erb') %>
@@ -0,0 +1,3 @@
1
+ (0...1000).map { |depth|
2
+ { depth: depth }
3
+ }
@@ -0,0 +1,6 @@
1
+ #include <boost/tuple/tuple.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ }
@@ -0,0 +1,6 @@
1
+ #include <boost/fusion/tuple.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::fusion::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ }
@@ -0,0 +1,6 @@
1
+ #include <boost/hana/list.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::hana::list(<%= (0...depth).to_a.join(', ') %>);
6
+ }
@@ -0,0 +1,6 @@
1
+ #include <tuple>
2
+
3
+
4
+ int main() {
5
+ auto go = std::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ }
@@ -0,0 +1,3 @@
1
+ (1...1000).map { |depth|
2
+ { depth: depth }
3
+ }
@@ -0,0 +1,7 @@
1
+ #include <boost/tuple/tuple.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ auto last = boost::get< <%= depth - 1 %> >(go);
7
+ }
@@ -0,0 +1,7 @@
1
+ #include <boost/fusion/tuple.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::fusion::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ auto last = boost::fusion::get< <%= depth - 1 %> >(go);
7
+ }
@@ -0,0 +1,7 @@
1
+ #include <boost/hana/list.hpp>
2
+
3
+
4
+ int main() {
5
+ auto go = boost::hana::list(<%= (0...depth).to_a.join(', ') %>);
6
+ auto last = boost::hana::at(boost::hana::size_t< <%= depth - 1 %> >, go);
7
+ }
@@ -0,0 +1,7 @@
1
+ #include <tuple>
2
+
3
+
4
+ int main() {
5
+ auto go = std::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
+ auto last = std::get< <%= depth - 1 %> >(go);
7
+ }
@@ -0,0 +1,3 @@
1
+ (0..1000).step(2).map { |depth|
2
+ { breadth: 1, depth: depth }
3
+ }
@@ -0,0 +1,18 @@
1
+ template <typename ...>
2
+ struct result { using type = result; };
3
+
4
+ struct f {
5
+ using type = f;
6
+ template <typename state, typename x>
7
+ using apply = typename result<typename state::type, typename x::type>::type;
8
+ };
9
+
10
+
11
+ <%= (0...breadth).map { |breadth|
12
+ xs = (0...depth).map { |depth| "x#{breadth}<#{depth}>" }
13
+ <<-EOS
14
+ struct state#{breadth} { using type = state#{breadth}; };
15
+ template <int> struct x#{breadth} { using type = x#{breadth}; };
16
+ using go#{breadth} = #{yield 'f', "state#{breadth}", xs};
17
+ EOS
18
+ }.join("\n") %>
@@ -0,0 +1,15 @@
1
+ #include <boost/hana/list.hpp>
2
+ #include <boost/hana/type.hpp>
3
+
4
+
5
+ <%= render('_main.erb') do |f, state, xs|
6
+ <<-EOS
7
+ decltype(
8
+ boost::hana::foldl(
9
+ boost::hana::lift<#{f}::apply>,
10
+ boost::hana::type<#{state}>,
11
+ boost::hana::list_t<#{xs.join(', ')}>
12
+ )
13
+ )::type
14
+ EOS
15
+ end %>
@@ -0,0 +1,10 @@
1
+ #define BOOST_MPL11_NO_ASSERTIONS
2
+ #include <boost/mpl11/list.hpp>
3
+
4
+
5
+ <%= render('_main.erb') do |f, state, xs|
6
+ cons = xs.foldr("boost::mpl11::list<>") { |x, tail|
7
+ "boost::mpl11::cons<#{x}, #{tail}>"
8
+ }
9
+ "boost::mpl11::foldl<#{f}, #{state}, #{cons}>::type"
10
+ end %>