In the constructor the function insert is called however the compile throws this error:
error: no matching function for call to 'List<int>::insert(List<int>::iterator, std::initializer_list<int>::const_iterator, std::initializer_list<int>::const_iterator)'|
As it shows in the error the compiler is picking the List<int>::iterator version of end() when there is a perfect List<int>::const_iterator version.
If comment out // iterator end() noexcept {};
The code works fine.
I have no idea how to fix this error.
I think the compiler should pick the right function but it doesn't.
One way would be to use cend().
I can do that, but the client code would not be able to insert an element at the end of the List because the same error I am facing right now will be thrown
1 2 3 4 5 6
...
List<int> list;
list.insert(list.end(), 33); // error would be thrown here
...
Another: make your const_iterator accept iterator.