Namespaces
Variants

std:: negate

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 T >
struct negate ;
(C++14 이전)
template < class T = void >
struct negate ;
(C++14 이후)

부정 연산을 수행하는 함수 객체입니다. 효과적으로 operator - T 타입의 인스턴스에 호출합니다.

목차

특수화

표준 라이브러리는 T 가 지정되지 않았을 때 std::negate 의 특수화를 제공하며, 이는 매개변수 타입과 반환 타입을 추론하도록 남겨둡니다.

매개변수와 반환 타입을 추론하는 - x 를 구현하는 함수 객체
(클래스 템플릿 특수화)
(C++14부터)

멤버 타입

유형 정의
result_type (C++17에서 사용 중단됨) (C++20에서 제거됨) T
argument_type (C++17에서 사용 중단됨) (C++20에서 제거됨) T

이 멤버 타입들은 공개적으로 상속받는 것을 통해 얻어집니다 std:: unary_function < T, T > .

(C++11 이전)

멤버 함수

operator()
인수의 부정(negation)을 반환합니다
(public member function)

std::negate:: operator()

T operator ( ) ( const T & arg ) const ;
(constexpr since C++14)

arg 의 부정(negation)을 반환합니다.

매개변수

arg - 부정을 계산할 값

반환 값

- arg 의 결과입니다.

예외

구현에서 정의된 예외를 throw할 수 있습니다.

가능한 구현

constexpr T operator()(const T& arg) const 
{
    return -arg;
}