C++ features by examples
Collaboration diagram for Constexpr lambda:

Functions

constexpr int const_inc (int n)
 

Variables

auto identity = [](int n) constexpr { return n; }
 
auto can_be_constexpr1 = [](auto a) { return a; }
 
auto can_be_constexpr2 = [](int(*fp)(int), auto a) { return fp(a); }
 
auto non_const = [](auto a) {static int s; return a; }
 
constexpr int(* inc )(int) = const_inc
 

Detailed Description

lambda

lambda-expressions-constexpr

Function Documentation

◆ const_inc()

constexpr int const_inc ( int  n)
constexpr

Definition at line 169 of file 17.cpp.

170{
171 return [n] { return n + 1; }();
172}

Variable Documentation

◆ can_be_constexpr1

auto can_be_constexpr1 = [](auto a) { return a; }

Definition at line 155 of file 17.cpp.

◆ can_be_constexpr2

auto can_be_constexpr2 = [](int(*fp)(int), auto a) { return fp(a); }

Definition at line 156 of file 17.cpp.

◆ identity

auto identity = [](int n) constexpr { return n; }

Definition at line 148 of file 17.cpp.

◆ inc

constexpr int(* inc) (int) ( int  ) = const_inc
constexpr

Definition at line 174 of file 17.cpp.

◆ non_const

auto non_const = [](auto a) {static int s; return a; }

Definition at line 164 of file 17.cpp.