What exactly does the first line here do? I'm having trouble understanding the syntax of the code on the right side of the assignment--specifically, the []()
and the trailing ()
. This looks like some sort of nameless inline function call? I've never seen this before.
HBRUSH hBrBlack = []() { return CreateSolidBrush(COLOR_BLACK); }();
For context, this is where the handle above is used (the question is about the code above):
HBRUSH MyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_LISTBOX)
{
int id(pWnd->GetDlgCtrlID());
if (id == ID_LST_MTRS)
{
pDC->SetTextColor(COLOR_WHITE);
pDC->SetBkColor(COLOR_BLACK);
return hBrBlack;
}
}
// All the rest
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}