std::plus - cppreference.com (original) (raw)
| | | | | ----------------------------- | | ------------- | | template<> class plus<void>; | | (since C++14) |
std::plus<void> is a specialization of std::plus with parameter and return type deduced.
Contents
[edit] Member types
[edit] Member functions
| | returns the sum of two arguments (public member function) [edit] | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
std::plus::operator()
| template< class T, class U > constexpr auto operator()( T&& lhs, U&& rhs ) const -> decltype(std::forward<T>(lhs) + std::forward<U>(rhs)); | | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | |
Returns the sum of lhs and rhs.
Parameters
Return value
std::forward<T>(lhs) + std::forward<U>(rhs).
[edit] Example
#include #include int main() { auto string_plus = std::plus{}; // “void” can be omitted std::string a = "Hello "; const char* b = "world"; std::cout << string_plus(a, b) << '\n'; }
Output: