Skip to content
Snippets Groups Projects
Commit cf42d11b authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Document issue with Dune::overload/Dune::orderedOverload and gcc 5/6

Document a potential issue and a workaround with `Dune::overload` and
`Dune::orderedOverload` for captureless lambdas on gcc 5 and 6.
Additionally this adds a test case for the problem making use
of the proposed workaound.
parent 1cc5fecb
Branches
Tags
1 merge request!668Document issue with Dune::overload/Dune::orderedOverload and gcc 5/6
Pipeline #18377 passed
......@@ -97,6 +97,12 @@ namespace Impl {
* Notice that the passed function objects are
* stored by value and must be copy-constructible.
*
* On gcc 5 and gcc 6 mixing templated overloads
* (i.e. using auto-parameter) and non-templated
* ones may not compile if both they are captureless
* lambdas. The problem can be avoided by capturing
* a dummy value.
*
* \ingroup CxxUtilities
*/
template<class... F>
......@@ -185,6 +191,12 @@ namespace Impl {
* Notice that the passed function objects are
* stored by value and must be copy-constructible.
*
* On gcc 5 and gcc 6 mixing templated overloads
* (i.e. using auto-parameter) and non-templated
* ones may not compile if both they are captureless
* lambdas. The problem can be avoided by capturing
* a dummy value.
*
* \ingroup CxxUtilities
*/
template<class... F>
......
......@@ -12,6 +12,11 @@
#include <dune/common/test/testsuite.hh>
struct Bar {
int bar() const { return 0; }
};
int main()
{
......@@ -92,6 +97,19 @@ int main()
<< "traversal of tuple called incorrect overloads";
}
{
// Check if templated and non-templed overloads work
// nicely together. The following should work with an
// empty capture list []. Unfortunately it does not on
// gcc 5 and gcc 6. As a workaround we capture a dummy
// value.
int dummyCapture=0;
auto f = Dune::overload(
[dummyCapture](const int& t) { t;},
[dummyCapture](const auto& t) { t.bar();});
f(0);
}
return test.exit();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment