From what I understand one can write template specializations for function template in the std namespace. I have written a CircularBuffer<T>
class and implemented a random access iterator for this class. As is the std::copy()
algorithm works with my custom iterators but it is not optimal. It iterates through the range and copies elements one by one. I could write a more optimal implementation for trivially copiable types by using std::memcpy()
on internal pointers.
My question is that even possible? I know how I would create an overload of std::copy()
as a template with output iterator being the template parameter. But that cannot be done since you can only write template specializations of function templates in the std namespace. Any help in pointing me in the right direction would be helpful. From what I could gather through Google, this can't be done, but I would love to be proven wrong :)