Notes from:

Modern C++ Tutorial

Simpler Core Language Features

Return Type

decltype and Trailing Return Type

// Function template to return product of two
// values of unknown types:
template<typename T, typename U>
auto product(const T &t, const U &u) -> decltype (t * u)
{
	return t * u;
}

// findNull: Given a container of pointers, return an
// iterator to the first null opointer (or the end
// iterator if none is found)
template<typename Cont>
auto findNull(const Cont &c) -> decltype(begin(c)) 
													//in C++14, don't need decltype
{                             
	auto it = begin(c);
	for (; it != end(c); ++it)
		if (*it == nullptr)
			break;
	return it;   //in C++14, return type deduced here
}

Multiple return values

//C++98
pair<set<string>::iterator, bool> result = myset.insert("Hello");
if(result.second) use(result.first);

//C++11
auto result = myset.insert("Hello");
if(result.second) use(result.first);

//C++11
tie(**iter, success**) = myset.insert("Hello");
if(success) use(iter);

Initializer

vector<int> foo()
{
	vector<int> v {10, 20, 30};
	v.insert(end(v), {40, 50, 60});
	return {100, 200, 300};
}

struct S
{
	int i, j;
};

int main()
{
	for (auto x: foo())
			cout << x << " ";
	cout << endl;

	S s1 = {5, 10};
	S s2{5, 10};
}

Lambdas and Local Variables

int main()
{
	vector<double> v {1.2, 4.7, 5, 9, 9.4};
	double target = 4.9;
	double epsilon = .3;

	auto endMacheds = partition(begin(v), end(v),
					[target, epsilon](double val)
					{ return fabs(target - val) < epsilon; });

	for_each(begin(v), endMaches, [](double d)
					{ cout << d << ' '; });
}

Generic Lambdas (C++14)

vector<shared_ptr<string>> vps;

sort(begin(vps), end(vps), []
		(const auto &p1, const auto &p2) { return *p1 < *p2 });

auto getsize = []
		(auto const& c) { return c.size(); };

Range