Tangentially-related, follow-on beginner question to a question that I had originally posted here.
In short: how (without using any of the standard library's containers) can I access the pointers of type T
that point to the first and last element of a list-initialization? In case my explanation is not understandable:
int x = {1, 2, 3, 4, 5}
If I wanted to create a custom class template<typename T> class array<T> {};
that I can list-initialize, it's my understanding that I could leverage std::initializer_list
to be able to do this.
My question is: how would I be able to replicate that behavior? It looks like it leverages std::begin() to do this, but (unless I'm mistaken) that still begs the question: how can I write code that says "return a pointer to the first element of a list to be allocated on the stack" and, at the same time, "return a pointer to the first-past-the-last element of a list to be allocated on the stack"?
I realize that there's a significant "reinventing-the-wheel" component to my question (i.e. why shouldn't I go ahead and use std::initializer_list
), but I just want to make sure I understand what the standard library is doing.