///////////////////
//////////////////
std::vector<int> a = {9, 8, 7};
std::vector<int> b = {1, 3, 4};
std::vector<int> c = a + b;
for (int i = 0; i < c.size(); i = i + 1) {
std::cout << c[i] << " ";
}
//10 11 11//
std::vector<int> operator + (std::vector<int> a, const std::vector<int>& b)
{
if(a.size()!=b.size())
{
throw std::range_error("sizes mismatch!");
}
for(size_t i=0;i!=a.size();++i)
{
a[i]+=b[i];
}
return a;
}
std::vector<int> operator + (const std::vector<int> &a, const std::vector<int> &b)
{
if(a.size()!=b.size())
{
throw std::range_error("sizes mismatch!");
}
vector<int> result;
result.reserve(a.size());
for(size_t i=0; i < a.size(); ++i)
{
result.push_back(a[i] + b[i]);
}
return result;
}
В листинге это видно в том числеВ каком?
T operator+(const T &a, const T2 &b);
.std::vector<int> operator + ( const std::vector<int>& left, const std::vector<int>& right )
{
if( left.size() != right.size() )
{
throw std::range_error("sizes mismatch!");
}
std::vector<int> result{ left };
for( size_t index = 0; index < right.size(); ++index )
{
result[ index ] += right[ index ];
}
return result;
}
For floating-point types with denormalization, min returns the minimum positive normalized value. Note that this behavior may be unexpected, especially when compared to the behavior of min for integral types. To find the value that has no values less than it, use numeric_limits::lowest.
std::numeric_limits::min()
можно сказать только то, что FLT_MIN
даже в C означает ровно то же самое.