CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// https://www.sololearn.com/Discuss/1657370/how-to-create-own-data-types-in-cpp
#include <algorithm>
#include <iostream>
#include <utility>
#include <memory>
#include <iterator>
template<typename T>
class List
{
public:
// default constructor
List() noexcept
: m_size{0}
, m_list{nullptr}
{}
// parametrized constructor
List(std::initializer_list<T> list) noexcept
: m_size{ std::size(list) }
{
if ( auto buffer = std::aligned_alloc(alignof(T), sizeof(T) * std::size(list)) )
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run