diff options
author | Adrian Kummerlaender | 2015-03-07 16:14:11 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-03-07 16:14:11 +0100 |
commit | cb2a79cd818fbfa50e7bdebd090e681a0073f9d5 (patch) | |
tree | 70c5a90977ae0772618be00dfb499eb5ee4cf63f | |
parent | 299781bccc5c7d1b212198b5a9a55ee9447603c5 (diff) | |
download | TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar.gz TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar.bz2 TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar.lz TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar.xz TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.tar.zst TypeAsValue-cb2a79cd818fbfa50e7bdebd090e681a0073f9d5.zip |
Changed `tav::Apply` implementation selection to template alias
* there is no reason to differ from the rest of the library and use inheritance in this instance
* added link to blog article on the _Scheme metaphor_ to `README.md`
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | example/turing/turing.cc | 6 | ||||
-rw-r--r-- | src/function/apply.h | 4 | ||||
-rw-r--r-- | src/function/detail/apply.h | 4 | ||||
-rw-r--r-- | src/function/detail/placeholder.h | 6 |
5 files changed, 12 insertions, 10 deletions
@@ -4,6 +4,8 @@ This library is a expanded reimplementation of my previous attempt at this problem: [ConstList](https://github.com/KnairdA/ConstList). As detailed in the appropriate [blog article](http://blog.kummerlaender.eu/article/a_look_at_compile_time_computation_in_cpp/) the mixed approach between generic lambda expressions, `constexpr` marked functions and template metaprogramming doesn't offer sufficient flexibility which led me to approach compile time computation in a slightly different manner via this new library. As one might notice this boils down to using _Scheme_ as a metaphor for C++ template metaprogramming. In fact all test cases and examples are documented by representing their logic in _Scheme_. +Furthermore an overview of this library alongside some background information is available in the form of a blog article on [using _Scheme_ as a metaphor for template metaprogramming](http://blog.kummerlaender.eu/article/using_scheme_as_a_metaphor_for_template_metaprogramming/). + ## Example // λ (length (filter odd? (list 1 2 3))) diff --git a/example/turing/turing.cc b/example/turing/turing.cc index 720697a..070bc16 100644 --- a/example/turing/turing.cc +++ b/example/turing/turing.cc @@ -9,7 +9,7 @@ using BLANK = machine::tape::BLANK; // (define mirror (list (list 1 1 0 2 'R') [...])) using mirror = tav::List< -// [state] [read] [write] [next state] [head movement] + // [state] [read] [write] [next state] [head movement] tav::List<tav::Size<1>, tav::Int<1>, tav::Int<0>, tav::Size<2>, tav::Char<'R'>>, tav::List<tav::Size<1>, tav::Int<0>, tav::Int<0>, void, tav::Char<'N'> >, tav::List<tav::Size<2>, tav::Int<1>, tav::Int<1>, tav::Size<2>, tav::Char<'R'>>, @@ -24,7 +24,7 @@ using mirror = tav::List< // (define busy_beaver (list (list 'A' 0 1 'B' 'R') [...])) using busy_beaver = tav::List< -// [state] [read] [write] [next state] [head movement] + // [state] [read] [write] [next state] [head movement] tav::List<tav::Char<'A'>, tav::Int<0>, tav::Int<1>, tav::Char<'B'>, tav::Char<'R'>>, tav::List<tav::Char<'A'>, tav::Int<1>, tav::Int<1>, tav::Char<'C'>, tav::Char<'L'> >, tav::List<tav::Char<'B'>, tav::Int<0>, tav::Int<1>, tav::Char<'A'>, tav::Char<'L'> >, @@ -35,7 +35,7 @@ using busy_beaver = tav::List< // (define binary_increment (list (list 0 '() '() 1 'L') [...])) using binary_increment = tav::List< -// [state] [read] [write] [next state] [head movement] + // [state] [read] [write] [next state] [head movement] tav::List<tav::Size<0>, BLANK, BLANK, tav::Size<1>, tav::Char<'L'>>, tav::List<tav::Size<0>, tav::Boolean<false>, tav::Boolean<false>, tav::Size<0>, tav::Char<'R'>>, tav::List<tav::Size<0>, tav::Boolean<true>, tav::Boolean<true>, tav::Size<0>, tav::Char<'R'>>, diff --git a/src/function/apply.h b/src/function/apply.h index 553ae7f..402b654 100644 --- a/src/function/apply.h +++ b/src/function/apply.h @@ -17,7 +17,7 @@ template < template<typename...> class Function, typename... Arguments > -struct Apply : Cond< +using Apply = Cond< Branch< GreaterThan<detail::count_placeholders<Arguments...>, Size<2>>, detail::apply_variadic<Function, Arguments...> @@ -33,7 +33,7 @@ struct Apply : Cond< Else< detail::apply_none<Function, Arguments...> > -> { }; +>; } diff --git a/src/function/detail/apply.h b/src/function/detail/apply.h index c06fe68..4b550e6 100644 --- a/src/function/detail/apply.h +++ b/src/function/detail/apply.h @@ -33,7 +33,7 @@ template < template<typename...> class Function, typename... Arguments > -struct apply_single : apply_variadic<Function, Arguments...> { +struct apply_single { template <typename Partial0> using function = typename apply_variadic< Function, @@ -45,7 +45,7 @@ template < template<typename...> class Function, typename... Arguments > -struct apply_pair : apply_variadic<Function, Arguments...> { +struct apply_pair { template <typename Partial0, typename Partial1> using function = typename apply_variadic< Function, diff --git a/src/function/detail/placeholder.h b/src/function/detail/placeholder.h index 8105de5..00818b7 100644 --- a/src/function/detail/placeholder.h +++ b/src/function/detail/placeholder.h @@ -13,7 +13,7 @@ namespace detail { struct placeholder_tag { }; -template <int Index> +template <std::size_t Index> struct placeholder : placeholder_tag { }; template <typename Type> @@ -28,8 +28,8 @@ struct resolve_placeholder { }; template < - typename Partials, - int Index + typename Partials, + std::size_t Index > struct resolve_placeholder<Partials, placeholder<Index>> { typedef Nth<Size<Index>, Partials> type; |