[STL] std::negate
C++/STL2024. 6. 23. 22:30[STL] std::negate

1. 개요std::negate는 C++11부터 도입된 표준 라이브러리의 일부이며, 함수형 프로그래밍 스타일을 지원하는 함수 객체(functor)이다. 단항 연산자로 입력된 값을 부정(negation)하는 역할을 한다. 즉, 입력된 값의 부호를 반대로 바꿔준다.2. 사용 예시#include #include // std::negateint main() { std::negate neg; // int 타입의 부정 함수 객체를 선언 int x = 10; int y = neg(x); // -x를 계산하여 y에 할당 std::cout 2.1. 결과 출력x = 10, y = -103. 참고사항3.1. 관련 문서https://en.cppreference.com/w/cpp/utility/functi..

728x90
반응형
image