I'm learning how to use lambda functions. Why doesn't my last lambda run automatically if not assigned to a variable? All the previous ones work as expected.
#include "stdafx.h"
#include <iostream>
#include <thread>
using namespace std;
int main()
{
std::thread t([]() {
std::cout << "thread function\n";
});
std::cout << "main thread\n";
t.join();
auto a = []() -> int {
return 1 + 2;
};
int n = a();
cout << n << endl;
auto b = []() -> void {
cout << "sup" << endl;
};
b();
//why doesn't this run automatically?
[]() -> void {
cout << "hellur!" << endl;
};
return 0;
}