aboutsummaryrefslogtreecommitdiff
path: root/articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-09-02 22:52:08 +0200
committerAdrian Kummerlaender2014-09-02 22:52:08 +0200
commit29343cb97795296fb2a0fbcd2ba17047034e8761 (patch)
treece02936f0f343ece8510b3e6dc593d11e30021e2 /articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md
parent5a68d6974ede7a7a9bb85c78e200b8a344bf5d18 (diff)
downloadblog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar.gz
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar.bz2
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar.lz
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar.xz
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.tar.zst
blog_content-29343cb97795296fb2a0fbcd2ba17047034e8761.zip
Fixed some broken content links
* the article "2014-07-11_mapping_arrays_using_tuples_in_cpp11" contained a full link to blog.kummerlaender.eu instead of an relative one * the page "input_xslt" contained a wrong cgit link
Diffstat (limited to 'articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md')
-rw-r--r--articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md b/articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md
index db55e00..99a8dce 100644
--- a/articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md
+++ b/articles/2014-07-11_mapping_arrays_using_tuples_in_cpp11.md
@@ -2,7 +2,7 @@
During my proof-of-concept implementation of external functions enabling [XSLT based static site generation](https://github.com/KnairdA/InputXSLT) I came upon the problem of calling a template method specialized on the Nth type of a `std::tuple` specialization using the Nth element of a array-like type instance as input. This was needed to implement a generic template-based interface for implementing [Apache Xalan](http://xalan.apache.org/xalan-c/index.html) external functions. This article aims to explain the particular approach taken to solve this problem.
-While it is possible to unpack a `std::tuple` instance into individual predefined objects using `std::tie` the standard library offers no such helper template for `unpacking` an array into individual objects and calling appropriate casting methods defined by a `std::tuple` mapping type. Sadly exactly this functionality is needed so that we are able to call a `constructDocument` member method of a class derived from the [`FunctionBase`](https://github.com/KnairdA/InputXSLT/blob/master/src/function/base.h) external function interface template class using static polymorphism provided through the [curiously recurring template pattern](https://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern). This interface template accepts the desired external function arguments as variadic template types and aims to provide the required validation and conversion boilerplate implementation. While we could recursively generate a `std::tuple` specialization instance from an array-like type using a approach simmilar to the one detailed in my article on [mapping binary structures as tuples using template metaprogramming](http://blog.kummerlaender.eu/artikel/mapping-binary-structures-as-tuples-using-template-metaprogramming) this wouldn't solve the problem of passing on the resulting values as individual objects. This is why I had to take the new approach of directly calling a template method on individual array elements using a `std::tuple` specialization as a kind of blueprint and passing the result values of this method to the `constructDocument` method as separate arguments.
+While it is possible to unpack a `std::tuple` instance into individual predefined objects using `std::tie` the standard library offers no such helper template for `unpacking` an array into individual objects and calling appropriate casting methods defined by a `std::tuple` mapping type. Sadly exactly this functionality is needed so that we are able to call a `constructDocument` member method of a class derived from the [`FunctionBase`](https://github.com/KnairdA/InputXSLT/blob/master/src/function/base.h) external function interface template class using static polymorphism provided through the [curiously recurring template pattern](https://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern). This interface template accepts the desired external function arguments as variadic template types and aims to provide the required validation and conversion boilerplate implementation. While we could recursively generate a `std::tuple` specialization instance from an array-like type using a approach simmilar to the one detailed in my article on [mapping binary structures as tuples using template metaprogramming](/article/mapping_binary_structures_as_tuples_using_template_metaprogramming) this wouldn't solve the problem of passing on the resulting values as individual objects. This is why I had to take the new approach of directly calling a template method on individual array elements using a `std::tuple` specialization as a kind of blueprint and passing the result values of this method to the `constructDocument` method as separate arguments.
Extracting array elements obviously requires some way of defining the appropriate indexes and mapping the elements using a tuple blueprint additionally requires this way to be statically resolvable as one can not pass a dynamic index value to `std::tuple_element`. So the first step to fullfilling the defined requirements involved the implementation of a template based index or sequence type.