The std::remove
returns the forward iterator, not a pointer.
template< class ForwardIt, class T >
ForwardIt remove( ForwardIt first, ForwardIt last, const T& value );
^^^^^^^^^^
In your case, it is of type
std::array<char, 48>::iterator
Therefore, you do not need to add the auto*
, rather let the compiler deduce the type for you. So you need simply auto
:
auto characters = std::remove(some_array.begin()
, some_array.begin() + length
, filtered_character);
In order to verify the type. see here
#include <type_traits> // std::is_same_v
auto characters = std::remove(some_array.begin()
, some_array.begin() + length
, filtered_character);
static_assert(std::is_same_v<decltype(characters), std::array<char, 48>::iterator>
, "Are not same!");
As a side note, the algorithm std::remove
will not actually remove any elements, but instead only move them to the end of the sequence, in such a way that, all "removed" elements fall behind a certain boundary in your range.
If your intention was to erase the elements, you should think of containers such as std::vector
, std::list
, etc with erase–remove idiom or simply std::erase
(Since C++20). It is not possible with std::array