On 10/06/2017 12:48, Tom Westerhout via Boost wrote:
I'm Tom Westerhout, one of this year's GSoC interns.
The module I'm planning to work on, StaticViews, is essentially a subset of Ranges TS optimised for usage with compile-time homogeneous datasets. It can be used to implement compile-time associative maps, compile-time checking of non-type constraints, and compile-time generation of datasets from other compile-time datasets. Some more explanation and motivating examples are on this page: https://boostgsoc17.github.io/static-map/doc/123_build/html/getting_started....
Do you think this would be a worthwhile addition to Boost? Is the choice to use Ranges TS as inspiration for the API wise, or would a different API (please, suggest one) be better? All comments are welcome.
Thanks in advance!
Just to mention that Tom is my student this year, and his proposal could greatly aid using the C++ compiler as a C++ interpreter at compile time. Here is an example of usage: ``` constexpr int xs[] = {8, -7, 10, -1, 8, -2, 5}; // Make a view of the constexpr array above with the first half // removed, then return the minimum valued item constexpr auto m = xs | drop(std::size(xs) / 2) | min(); static_assert(m == -2); ``` In his page he gives some motivating examples: 1. A view statically mapping keys to values. If you only ever modify the mapped values in your code and not the keys, this lets you totally eliminate runtime overhead altogether as all lookup is done at compile time. 2. Checking printf format strings to make sure the input has the correct type, else fail to compile. 3. Generating a 32 bit and a 1 bit compile time view of a 24 bit colour bitmap stored in a static const array of char e.g. icons. 4. At compile time match up longitude and latitude of two externally supplied datasets for closeness, and create a static runtime map of the matching items. There are lots of use cases for this stuff. Historically we used bits of Python or shell script to preprocess small bits of static data into the build. From C++ 14 and especially 17 onwards, one can write all that preprocessing in straight C++ using Ranges TS idiomatic code and have the C++ compiler do it instead, with the optimiser typically able to do a far better job at optimising than when faced with a large extern array it cannot assume will not get modified. Looking forward to seeing what people think. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/