14 - std::initializer_list and Modern C++ Initialization () vs { }

preview_player
Показать описание
We will learn how to use std::initializer_list, and C++ initialization () vs {}
We will also learn the difference between aggregate type and nonaggregate type.

Standard library header initializer_list

Class template argument deduction(since C++17)

13 - Class Template Parameter Type Deduction Guide

Break the tie between the enclosing class and its member constructor

std::unique_ptr 02 - How to use std::make_unique for std::unique_ptr

01 - C++ Type Functions, Modern C++ Programming, Motivation

Download Source Code:
Рекомендации по теме
Комментарии
Автор

aggregate 타입도 deduction guide 되는것 같습니다.
template <typename T>
class AggregateType
{
public:
T m_value;
friend std::ostream& operator<<( std::ostream& os, const AggregateType& arg )
{
return os << arg.m_value;
}
};

template <typename T>
AggregateType(T) -> AggregateType<T>;

int main()
{
AggregateType a{100};
std::cout << a << '\n';
}

hyunhocho
Автор

Really nice video! Keep it up man! Underrated channel.

comradepeter
Автор

Hi, Thomas, if i have several customed constructors and tens of class members, then i have to initialize them in all constructors. Is there a way that using initializer list to initialize members without having to write for all constructors?

eitxzh
welcome to shbcf.ru