<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MinGW Thread Support Workaround]]></title><description><![CDATA[<p>Ich leide gerade darunter, dass meine lieblings MinGW-W64 Distro keine std::thread Implementierung bietet. (<a href="http://nuwen.net" rel="nofollow">nuwen.net</a>, von STL (der Person))</p>
<p>Frage 1) Kann man std::mutex [, ...] und boost::thread mischen ohne sich gedanken zu machen?</p>
<p>Frage 2) Ist folgender Workaround Hack zu dirty? (zusammengebastelt mit ein bisschen Hilfe von StackOverflow).</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;
#include &lt;type_traits&gt;

// it hurts to look at this very evil thing.
namespace std {
    class thread;
}

#include &lt;thread&gt;

namespace tfix {

    template&lt; typename T&gt;
    struct has_destructor
    {
        template &lt;typename A&gt;
        static std::true_type test(decltype(std::declval&lt;A&gt;().~A()) *) {
            return std::true_type();
        }

        template&lt;typename A&gt;
        static std::false_type test(...) {
            return std::false_type();
        }

        typedef decltype(test&lt;T&gt;(0)) type;

        static const bool value = type::value;
    };

    template &lt;unsigned hasStdThreads&gt;
    struct ThreadSelector {
        using thread = boost::thread;
    };

    template &lt;&gt;
    struct ThreadSelector &lt;1&gt; {
        using thread = std::thread;
    };

    using thread = ThreadSelector&lt;has_destructor&lt;std::thread&gt;::value&gt;::thread;
}

int main()
{
    tfix::thread thr([](){std::cout &lt;&lt; &quot;Hello\n&quot;;});
    thr.join(); // EDIT - WICHTIG! ...ok war eh nur zur demonstration :P
    return 0;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/328718/mingw-thread-support-workaround</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 12:42:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/328718.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Oct 2014 19:35:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 20:33:03 GMT]]></title><description><![CDATA[<p>Ich leide gerade darunter, dass meine lieblings MinGW-W64 Distro keine std::thread Implementierung bietet. (<a href="http://nuwen.net" rel="nofollow">nuwen.net</a>, von STL (der Person))</p>
<p>Frage 1) Kann man std::mutex [, ...] und boost::thread mischen ohne sich gedanken zu machen?</p>
<p>Frage 2) Ist folgender Workaround Hack zu dirty? (zusammengebastelt mit ein bisschen Hilfe von StackOverflow).</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;
#include &lt;type_traits&gt;

// it hurts to look at this very evil thing.
namespace std {
    class thread;
}

#include &lt;thread&gt;

namespace tfix {

    template&lt; typename T&gt;
    struct has_destructor
    {
        template &lt;typename A&gt;
        static std::true_type test(decltype(std::declval&lt;A&gt;().~A()) *) {
            return std::true_type();
        }

        template&lt;typename A&gt;
        static std::false_type test(...) {
            return std::false_type();
        }

        typedef decltype(test&lt;T&gt;(0)) type;

        static const bool value = type::value;
    };

    template &lt;unsigned hasStdThreads&gt;
    struct ThreadSelector {
        using thread = boost::thread;
    };

    template &lt;&gt;
    struct ThreadSelector &lt;1&gt; {
        using thread = std::thread;
    };

    using thread = ThreadSelector&lt;has_destructor&lt;std::thread&gt;::value&gt;::thread;
}

int main()
{
    tfix::thread thr([](){std::cout &lt;&lt; &quot;Hello\n&quot;;});
    thr.join(); // EDIT - WICHTIG! ...ok war eh nur zur demonstration :P
    return 0;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2423685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423685</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Thu, 23 Oct 2014 20:33:03 GMT</pubDate></item><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 19:40:34 GMT]]></title><description><![CDATA[<p>Spricht etwas gegen eine andere MinGW Distro?<br />
Ich verwende TDM-GCC mit pthreads und habe thread-Support.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2423686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423686</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Thu, 23 Oct 2014 19:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 19:58:04 GMT]]></title><description><![CDATA[<p>Es gibt jede Menge verschiedene gccs und der neuste hat eigentlich alle C++11 Features dabei.</p>
<p>EDIT: Wenn du aus irgendeinem Grund nicht wechseln willst: Boost hat fast die gleichen Threads dabei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2423691</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423691</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Thu, 23 Oct 2014 19:58:04 GMT</pubDate></item><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 20:27:56 GMT]]></title><description><![CDATA[<p>Marthog schrieb:</p>
<blockquote>
<p>EDIT: Wenn du aus irgendeinem Grund nicht wechseln willst: Boost hat fast die gleichen Threads dabei.</p>
</blockquote>
<p>Der Source oben typedefed tfix::thread entweder mit std::thread wenn vorhanden und wenn nicht mit boost::thread.</p>
<p>----------------------------------------------------------------</p>
<p>ich habe gerade TDM-GCC installiert und bau gleich boost.<br />
Was mich am meisten stört sind die libs, wo STL gleich ein paar nette mitliefert<br />
(ohne boost weigere ich mich zu programmieren, zlib habe ich schon oft gebraucht, gdb binaries sind nicht überall gleich mit drin, die LAME lib habe ich schon verwendet, ...)</p>
<p>Ich hätte so gern einfach ein</p>
<blockquote>
<blockquote>
<p>libman -S boost<br />
libman -S zlib<br />
...</p>
</blockquote>
</blockquote>
<p>(oder ähnlich)<br />
EDIT: mit dem passenden compiler natürlich. Mir ist schon klar, dass ich hier nicht mischen kann. Vermutlich ist das bauen mit all den Optionen einfach zu individuell, als dass jemand sowas machen würde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Nuget von VisualStudio finde ich für C++ libs auch eher dürftig. (Wobei ich den Visual Studio Compiler lieber aus dem Weg gehe, wenn ich kann.)</p>
<p>----------------------------------------------------------------</p>
<p>Ich entwickele mittlerweile mit dem Grundsatz: Was auf Linux läuft muss auch auf Windows laufen und andersrum. (Auch weil ich beide Betriebssysteme nutze)<br />
Und ich will mich auch nicht auf den C++ Implementierungsstatus vom VC++ reduzieren.</p>
<p>EDIT 2: Ich habe ja sonst nichts gegen Windows, aber entwickeln ist auf linux [ArchLinux &lt;3] sooo schön im Vergleich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2423701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423701</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Thu, 23 Oct 2014 20:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 20:41:36 GMT]]></title><description><![CDATA[<p>Tim06TR schrieb:</p>
<blockquote>
<blockquote>
<blockquote>
<p>libman -S boost<br />
libman -S zlib<br />
...</p>
</blockquote>
</blockquote>
<p>(oder ähnlich)</p>
</blockquote>
<p>MSYS2?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2423707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423707</guid><dc:creator><![CDATA[EinGast]]></dc:creator><pubDate>Thu, 23 Oct 2014 20:41:36 GMT</pubDate></item><item><title><![CDATA[Reply to MinGW Thread Support Workaround on Thu, 23 Oct 2014 21:47:54 GMT]]></title><description><![CDATA[<p>EinGast schrieb:</p>
<blockquote>
<p>Tim06TR schrieb:</p>
<blockquote>
<blockquote>
<blockquote>
<p>libman -S boost<br />
libman -S zlib<br />
...</p>
</blockquote>
</blockquote>
<p>(oder ähnlich)</p>
</blockquote>
<p>MSYS2?</p>
</blockquote>
<p>... Ich liebe dich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Damit sind alle Probleme gelöst (auch schon ausprobiert).<br />
Habe die libs einfach da und threads funktionieren auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2423715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2423715</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Thu, 23 Oct 2014 21:47:54 GMT</pubDate></item></channel></rss>