Namespaces
Variants

std:: negate<void>

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
헤더 파일에 정의됨 <functional>
template <>
class negate < void > ;
(C++14 이후)

std:: negate <> 는 매개변수와 반환 타입이 추론된 std::negate 의 특수화입니다.

목차

멤버 타입

타입 정의
is_transparent unspecified

멤버 함수

operator()
인자의 부호를 반전하여 반환합니다
(public member function)

std::negate<void>:: operator()

template < class T >

constexpr auto operator ( ) ( T && arg ) const

- > decltype ( - std:: forward < T > ( arg ) ) ;

arg 의 부정(negation) 결과를 반환합니다.

매개변수

arg - 부정할 값

반환 값

- std:: forward < T > ( arg ) .

예제

#include <complex>
#include <functional>
#include <iostream>
int main()
{
    auto complex_negate = std::negate<void>{}; // "void"는 생략 가능
    constexpr std::complex z(4, 2);
    std::cout << z << '\n';
    std::cout << -z << '\n';
    std::cout << complex_negate(z) << '\n';
}

출력:

(4,2)
(-4,-2)
(-4,-2)