senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. S.H. (sh@gamelinks007.net@gamelinks007.net)'s status on Friday, 07-Dec-2018 23:47:09 JST S.H. S.H.

    お、templateにラムダ式渡してthreadでよしなにできた?

    #include <iostream>
    #include <future>
    #include <array>
    #include <functional>

    template <typename T, typename F>
    void func(const T& t, F&& f) {
    f(t);
    }

    int main() {
    std::array<std::thread, 9> th_array;

    std::function<void(int)> f = [](int i){std::cout << i;};

    for(int i =0; i < 9; i++)
    th_array[i] = std::thread(func<int, decltype(f)>, i, f);

    for(auto&& t : th_array)
    t.join();

    return 0;
    }

    In conversation Friday, 07-Dec-2018 23:47:09 JST from gamelinks007.net permalink

    Feeds

    • Activity Streams
    • RSS 2.0
    • Atom
    • Help
    • About
    • FAQ
    • TOS
    • Privacy
    • Source
    • Version
    • Contact

    senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

    Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.