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
// ---------------------------------- | |
// example 1 | |
const int i = 0; // decltype(i) is const int | |
bool f(const Widget& w); // decltype(w) is const Widget& | |
// decltype(f) is bool(const Widget&) | |
struct Point { | |
int x, y; // decltype(Point::x) is int | |
} // decltype(Point::y) is int |
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
// ---------------------------------- | |
// example 1 | |
auto x = 26; // x is int | |
const auto cx = x; // cx is const int | |
const auto& rx = x; // rx is const int& | |
auto&& uref1 = x; // uref1 is int& | |
auto&& uref2 = cx; // uref2 is const int& | |
auto&& uref3 = 27; // uref3 is int&& | |
// ---------------------------------- |
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
// ---------------------------------- | |
// example 1 | |
template<typename T> | |
void f(const T& param); | |
int x = 0; | |
const int cx = x; | |
const int& rx = x; | |
f(x); // param is const int& | |
f(cx); // param is const int& |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ |
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
#pragma once | |
#include <thread> | |
#include <future> | |
#include <iostream> | |
#include <functional> | |
class SuspendThread { | |
private: | |
std::thread task; | |
std::promise<void> Psuspend; | |
public: |
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
#pragma once | |
#include <thread> | |
#include <future> | |
#include <iostream> | |
class SuspendThread { | |
private: | |
std::function<void()> func; | |
std::thread task; |
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
class SuspendThread { | |
private: | |
std::thread task; | |
std::promise<void> Psuspend; | |
public: | |
template<typename FN_, typename ... Arguments> | |
SuspendThread(FN_ func, Arguments&& ... args) | |
{ | |
auto fut_suspend = Psuspend.get_future(); |
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
std::vector<std::function<void()>> fs; | |
class Widget | |
{ | |
public: | |
void get_func() | |
{ | |
int m = this->member; | |
fs.emplace_back([m]() | |
{ |
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
std::vector<std::function<void()>> fs; | |
class Widget | |
{ | |
public: | |
void get_func() | |
{ | |
fs.emplace_back([=]() | |
{ | |
std::cout << member << std::endl; |
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 CallbackFunction(std::string& str) | |
{ | |
auto writeStream = FileOpen('another.txt'); | |
writeStream.write(str); | |
} | |
auto readStream = FileOpen('callback.txt'); | |
readStream.ReadEndAsync(CallbackFunction); |
NewerOlder