This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cl /EHsc /std:c++latest /permissive- /O2 word_frequencies.cpp | |
#include <cctype> | |
#include <cstdio> | |
#include <algorithm> | |
#include <charconv> | |
#include <fstream> | |
#include <string> | |
#include <string_view> | |
#include <unordered_map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void do_thing(); | |
std::thread t1{[] { std::cout<<"Hello, World!\n"; }}; | |
std::thread t2{do_thing}; | |
t1.join(); | |
t2.join(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// most common use case for std::thread, the function invoke ctor | |
template<typename Function, typename... Args> | |
explicit thread(Function&& f, Args&&... args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DWORD WINAPI DoThing( LPVOID ); | |
DWORD ThreadID; // why? | |
auto threadHandle = CreateThread( | |
NULL, // default security attributes | |
0, // default stack size | |
(LPTHREAD_START_ROUTINE) DoThing, | |
NULL, // no thread function arguments | |
0, // default creation flags | |
&ThreadID); // receive thread identifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HANDLE WINAPI CreateThread( | |
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, | |
_In_ SIZE_T dwStackSize, | |
_In_ LPTHREAD_START_ROUTINE lpStartAddress, | |
_In_opt_ LPVOID lpParameter, | |
_In_ DWORD dwCreationFlags, | |
_Out_opt_ LPDWORD lpThreadId | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct circle_t; | |
struct triangle_t; | |
struct square_t; | |
struct shape_t { | |
using visitor_t = vdsp::visitor_t<circle_t, triangle_t, square_t>; | |
virtual void accept(const visitor_t&) const = 0; | |
virtual void do_thing() const = 0; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> // std::array | |
#include <iostream> // std::cout | |
#include <iterator> // std::begin, std::end, std::distance | |
#include <tuple> // std::tuple | |
#include <type_traits> // std::decay_t | |
#include <utility> // std::integer_sequence, std::forward | |
#include <vector> // std::vector | |
namespace detail | |
{ |