Files
qtpromise/tests/auto/qtpromise/cpp14/tst_argsof_lambda_auto.cpp
Simon Brunel 6deec9f51f Fix support for auto args in constructor callbacks
Broken since 78417b5, this bug creates an infinite recursion at runtime while trying to resolve the QPromise<T> template constructor if the given callback is either an invalid function or a valid callback but using auto args (C++14).

Related warning: C4717: recursive on all control paths, function will cause runtime stack overflow.
2020-03-22 17:50:16 +01:00

34 lines
855 B
C++

/*
* Copyright (c) Simon Brunel, https://github.com/simonbrunel
*
* This source code is licensed under the MIT license found in
* the LICENSE file in the root directory of this source tree.
*/
#include <QtPromise>
#include <QtTest>
using namespace QtPromisePrivate;
class tst_cpp14_argsof_lambda_auto : public QObject
{
Q_OBJECT
private Q_SLOTS:
void lambdaAutoArgs();
};
QTEST_MAIN(tst_cpp14_argsof_lambda_auto)
#include "tst_argsof_lambda_auto.moc"
void tst_cpp14_argsof_lambda_auto::lambdaAutoArgs()
{
auto lOneArg = [](auto) {};
auto lManyArgs = [](const auto&, auto, auto) {};
auto lMutable = [](const auto&, auto) mutable {};
Q_STATIC_ASSERT((ArgsOf<decltype(lOneArg)>::count == 0));
Q_STATIC_ASSERT((ArgsOf<decltype(lManyArgs)>::count == 0));
Q_STATIC_ASSERT((ArgsOf<decltype(lMutable)>::count == 0));
}