I can't understand why they won't work yet I have used this functions for a thousand years, and now they just decided otherwise, throwing all over, I don't get it.
void print(int array[]) is the same as void print(int* array): arrays of unknown size decays to pointers. And std::begin/end does not work on pointers. There is simply no way to know array size after it decays to pointer.
To work with normal arrays size of which is known at compile time, you can do something like:
1 2 3 4 5 6 7 8 9 10 11 12
template<typename T, std::size_t N>
void print(T (&array)[N])
{
for(auto i = std::begin(array); i != std::end(array); i++)
std::cout << *i << ' ';
}
int main()
{
int foo[5] = {1, 3, 5, 4, 2};
print(foo);
}
replace takes parameters as (from, to, what_to_replace, replace_with_what). Two last parameters should be of the same type. 0 is of type intvec.size() is of type std::vector<int>::size_type
They both can be converted to each other, so compiler does not know what type to use.
You need to tell it what to do: std::replace(vec.begin(), vec.end(), 0, static_cast<int>(vec.size()));
Thank you @Minnippa , @JLBorges void print(int array[]) is the same as void print(int* array[]): I dint know this , I thought all arrays are equivalent and dint realize that std::begin () arguments must be of know size, Thanks. For the examples they're workin' Btw i will save them and try understand them, The template part takes my mind into circles , I'll try read on templates.
I also dint realize Two last parameters should be of the same type. /// for std::replace