Skip to content

irrequietus/clause

Repository files navigation

clause

What this is all about

'clause' is a C++ metaprogramming library licensed under the Mozilla Public License 2.0. The following is the current list of its sublibrary components.

  • ppmpf (preprocessor metaprogramming framework)
  • ample (another metaprogramming library etude)

There are no third party library dependencies other than very minimal C++14 standard library support (to almost none) for using this library. However, it is very important that you use a fully C++14 compliant compiler. Library is transitioning from C++11 to C++14 and beyond ina a relatively "unstable" manner, build system will provide hints. Check development branches like ampl2-dev for edge, unstable features. An example of how parameter packs can be manipulated for several uses through operator driven semantics in development so far:

#include <clause/ample/base/atpp.hh>
#include <type_traits> // for std::is_same

// T... must be between 0 and 20 types in size while
// consisting of a repeating pattern of its first half;
// repeat it 8 times and instantiate a Super<...> class
// template with type indexes 1,3,5,0,0,7 then create
// a pack from of indices [3,5) of the resulting pack.
// Stranger things can happen.

template<typename...>
struct test{};

template<typename... T>
auto example1(T...)
  -> templify((test) ( (T...){0,20}[2]^8)(1,3,5,0,0,7)
                              >>= {3,5} );

int main() {
    // notice alternation of int/double
    return std::is_same<
           decltype(example1(1,2.3,3,4.3,5,6.5,7,8.6))
         , test<int,int>
     >::value;
}

Testing the code available

Tests are provided for clause using its own testing framework, which itself is pretty much a work in progress. New tests are added regularly and they are used in order to ascertain proper library functionality.

If you wish to just run the tests available for clause, simply clone the git repository and run make as follows in your terminal:

git clone git://github.com/irrequietus/clause.git
cd clause
./autogen.sh
./configure
make test

If you wish to get ANSI coloured output for the tests, do the following variation of the previously mentioned commands in your terminal:

git clone git://github.com/irrequietus/clause.git
cd clause
./autogen.sh
./configure --enable-ansi-colors
make test

It is now possible to use --with-compiler=<compiler path here> to specify a particular compiler path to be used during make targets. The make test command adds a -DUSE_TEST_EXPANSION to the flags using during tests, allowing for test macro expansion to occur only during tests.

In order to run compile and run a single test within the subdirectories for ample and / or ppmpf, after properly configuring the package as above run something like the example below, properly substituting "testname1" and "testname2":

make just ample/testname1.cc
make just ppmpf/testname2.cc

This will result in just compiling and running the test you are interested in.

Reporting bugs and other issues

Please report any issues over at https://github.com/irrequietus/clause/issues

About

A C++ metaprogramming library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages