Kaydet (Commit) 53e414df authored tarafından Milian Wolff's avatar Milian Wolff Kaydeden (comit) Thorsten Behrens

Fix compilation with GCC 4.8

Workaround a bug in variadic template parameter pack expansion in
lambdas that affects GCC 4.8. The workaround expands the pack outside
the lambda into a custom functor that then calls readIpcArgs.

Change-Id: I7a2d8572a6f2b330bb22a4f18f5cc13fd7ef9b45
Reviewed-on: https://gerrit.libreoffice.org/48895Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 53a68280
......@@ -71,10 +71,43 @@ public:
std::string readResponseLine();
// workaround gcc <= 4.8 bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55914
template <int...> struct seq
{
};
template <int N, int... S> struct gens : gens<N - 1, N - 1, S...>
{
};
template <int... S> struct gens<0, S...>
{
typedef seq<S...> type;
};
template <typename... Args> struct ArgsReader
{
ArgsReader(Args&... args)
: m_args(args...)
{
}
void operator()(std::istream& stream)
{
callFunc(stream, typename gens<sizeof...(Args)>::type());
}
private:
template <int... S> void callFunc(std::istream& stream, seq<S...>)
{
readIpcArgs(stream, std::get<S>(m_args)...);
}
std::tuple<Args&...> m_args;
};
template <typename... Args> void readResponse(uint64_t id, Args&... args)
{
// read synchronously from a background thread and run the eventloop until the value becomes available
// this allows us to keep the GUI responsive and also enables access to the LO clipboard
ArgsReader<Args...> argsReader(args...);
await(std::async(std::launch::async, [&]() {
while (true)
{
......@@ -92,7 +125,7 @@ public:
if (m_incomingResponse == id)
{
// the response we are waiting for came in
readIpcArgs(m_responseStream, args...);
argsReader(m_responseStream);
m_incomingResponse = 0;
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment