Following code is undefined behavior?
int main()
{
int x[1] = { 0 };
x + 1; // This is not undefined behavior.
int y = 0;
&y + 1; // Is this undefined behavior?
}
I want to use <algorithm>
functions with non‐array object. e.g.
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
int x;
// Is this undefined behavior?
std::copy(&x, &x + 1, std::ostream_iterator<int>(std::cout));
}