SlideShare a Scribd company logo
Lambdas in
unevaluated contexts
unevaluated contexts(미평가 문맥)
어떤 함수를 평가(실행 혹은 호출) 없이 사용할 수 있는 문맥
Lambdas in unevaluated contexts (C++ 20 이전)
Lambdas in unevaluated contexts (C++ 20 이후)
람다 표현식은 평가되지 않은 표현식, 템플릿 인수, 별칭 선언, typedef 선언 및 함수
본문과 함수의 기본 인수를 제외한 함수(또는 함수 템플릿) 선언에서 사용할 수
없습니다.
템플릿
미평가 문맥에서도 캡쳐
C++ 20 부터 가능
name mangling
name mangling?
C++ 에서는 오버로딩을 지원하기 때문에 컴파일러는 함수 인자에 따라 내부에서
구분이 가능한 다른 이름으로 만들어 주는 것. 컴파일러마다 만들어내는 이름은
조금씩 다르다.
기존에는 람다 클로저(객체) 별로 다른 타입을 가지고 있었지만 기존 방식으로는
미평가 문맥에 대응을 할 수 없기 때문에 맹글링 규칙이 변경되었다
https://stackoverflow.com/questions/55722362/lambdas-in-unevaluated-contexts-until-c20
Lambdas in unevaluated contexts (C++ 20 이전)
Lambdas in unevaluated contexts (C++ 20 이후)

More Related Content

More from 진화 손

C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
C++ 20 Make stateful allocator propagation more consistent for operator+(basi...C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
진화 손
 
C++ 20 Unevaluated asm-declaration in constexpr functions
C++ 20 Unevaluated asm-declaration in constexpr functionsC++ 20 Unevaluated asm-declaration in constexpr functions
C++ 20 Unevaluated asm-declaration in constexpr functions
진화 손
 
C++20 Utility functions to implement uses-allocator construction
C++20 Utility functions to implement uses-allocator constructionC++20 Utility functions to implement uses-allocator construction
C++20 Utility functions to implement uses-allocator construction
진화 손
 
C++ 20 std__reference_wrapper for incomplete types
C++ 20 std__reference_wrapper for incomplete typesC++ 20 std__reference_wrapper for incomplete types
C++ 20 std__reference_wrapper for incomplete types
진화 손
 
C++ 20 Stronger Unicode requirements
C++ 20 Stronger Unicode requirementsC++ 20 Stronger Unicode requirements
C++ 20 Stronger Unicode requirements
진화 손
 
C++20 Concepts library
C++20 Concepts libraryC++20 Concepts library
C++20 Concepts library
진화 손
 
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine
진화 손
 
C++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rulesC++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rules
진화 손
 
C++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rulesC++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rules
진화 손
 
C++20 explicit(bool)
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)
진화 손
 
C++20 std::map::contains
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains
진화 손
 
C++20 Comparing unordered containers
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers
진화 손
 
C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]
진화 손
 
C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>
진화 손
 
C++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptrC++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptr
진화 손
 
C++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fieldsC++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fields
진화 손
 
C++ 20 constexpr for algorithm and utility
C++ 20 constexpr for  algorithm and utilityC++ 20 constexpr for  algorithm and utility
C++ 20 constexpr for algorithm and utility
진화 손
 
C++17 init-statements for if and switch
C++17 init-statements for if and switchC++17 init-statements for if and switch
C++17 init-statements for if and switch
진화 손
 
C++17 Aggregate classes with base classes
C++17 Aggregate classes with base classesC++17 Aggregate classes with base classes
C++17 Aggregate classes with base classes
진화 손
 
C++17 std::byte
C++17 std::byteC++17 std::byte
C++17 std::byte
진화 손
 

More from 진화 손 (20)

C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
C++ 20 Make stateful allocator propagation more consistent for operator+(basi...C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
C++ 20 Make stateful allocator propagation more consistent for operator+(basi...
 
C++ 20 Unevaluated asm-declaration in constexpr functions
C++ 20 Unevaluated asm-declaration in constexpr functionsC++ 20 Unevaluated asm-declaration in constexpr functions
C++ 20 Unevaluated asm-declaration in constexpr functions
 
C++20 Utility functions to implement uses-allocator construction
C++20 Utility functions to implement uses-allocator constructionC++20 Utility functions to implement uses-allocator construction
C++20 Utility functions to implement uses-allocator construction
 
C++ 20 std__reference_wrapper for incomplete types
C++ 20 std__reference_wrapper for incomplete typesC++ 20 std__reference_wrapper for incomplete types
C++ 20 std__reference_wrapper for incomplete types
 
C++ 20 Stronger Unicode requirements
C++ 20 Stronger Unicode requirementsC++ 20 Stronger Unicode requirements
C++ 20 Stronger Unicode requirements
 
C++20 Concepts library
C++20 Concepts libraryC++20 Concepts library
C++20 Concepts library
 
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine
 
C++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rulesC++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rules
 
C++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rulesC++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rules
 
C++20 explicit(bool)
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)
 
C++20 std::map::contains
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains
 
C++20 Comparing unordered containers
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers
 
C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]
 
C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>
 
C++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptrC++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptr
 
C++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fieldsC++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fields
 
C++ 20 constexpr for algorithm and utility
C++ 20 constexpr for  algorithm and utilityC++ 20 constexpr for  algorithm and utility
C++ 20 constexpr for algorithm and utility
 
C++17 init-statements for if and switch
C++17 init-statements for if and switchC++17 init-statements for if and switch
C++17 init-statements for if and switch
 
C++17 Aggregate classes with base classes
C++17 Aggregate classes with base classesC++17 Aggregate classes with base classes
C++17 Aggregate classes with base classes
 
C++17 std::byte
C++17 std::byteC++17 std::byte
C++17 std::byte
 

C++ 20 Lambdas in unevaluated contexts