C++17 Dynamic memory allocation for over-aligned data

Dynamic memory allocation
for over-aligned data
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html
제목 번역
C++ 11 에 alignas 키워드가 추가 됨
이 alignas로 설정한 크기가 __STDCPP_DEFAULT_NEW_ALIGNMENT__ 를 넘는
클래스를 동적할당 할 경우 프로그래머가 기대한 대로 동작하지 않는 문제가
있었다고 함
__STDCPP_DEFAULT_NEW_ALIGNMENT__ : 컴퓨터마다 다르니 확인 필요
회사 컴은 8. 집 컴은 16
std::align_val_t
new, delete 오버로딩 함수를 추가하기 위한 키워드 선언
https://en.cppreference.com/w/cpp/memory/new/align_val_t
새로운 new, delete 추가
알아서 오버로딩 되기 때문에
코드 사용법이 변경되지는
않는다
align 사이즈가
__STDCPP_DEFAULT_NEW_
ALIGNMENT__ 를 넘으면
operator new(sizeof(T),
std::align_val_t(alignof(T)))
이렇게 변환이 되어서
오버로딩되는 거 같음...
https://en.cppreference.com/w/cpp/language/new
https://en.cppreference.com/w/cpp/memory/new/operato
r_new
Visual Studio
VS 2017 에서 부터 사용가능
옛날 버전에는 /Zc:alignedNew 키워드를 사용해야 해당 기능을 사용할 수 있었으나
최신 버전에서는 기본으로 포함되어 있음
https://learn.microsoft.com/ko-kr/cpp/build/reference/zc-alignednew?view=msvc-170
1 de 5

Recomendados

C++ 20 class template argument deduction for alias templates por
C++ 20 class template argument deduction for alias templatesC++ 20 class template argument deduction for alias templates
C++ 20 class template argument deduction for alias templates진화 손
3 visualizações3 slides
C++ 20 Make stateful allocator propagation more consistent for operator+(basi... por
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...진화 손
5 visualizações5 slides
C++ 20 Unevaluated asm-declaration in constexpr functions por
C++ 20 Unevaluated asm-declaration in constexpr functionsC++ 20 Unevaluated asm-declaration in constexpr functions
C++ 20 Unevaluated asm-declaration in constexpr functions진화 손
4 visualizações3 slides
C++20 Utility functions to implement uses-allocator construction.pdf por
C++20 Utility functions to implement uses-allocator construction.pdfC++20 Utility functions to implement uses-allocator construction.pdf
C++20 Utility functions to implement uses-allocator construction.pdf진화 손
7 visualizações9 slides
C++ 20 std__reference_wrapper for incomplete types por
C++ 20 std__reference_wrapper for incomplete typesC++ 20 std__reference_wrapper for incomplete types
C++ 20 std__reference_wrapper for incomplete types진화 손
8 visualizações2 slides
C++ 20 Stronger Unicode requirements por
C++ 20 Stronger Unicode requirementsC++ 20 Stronger Unicode requirements
C++ 20 Stronger Unicode requirements진화 손
5 visualizações2 slides

Mais conteúdo relacionado

Mais de 진화 손

C++ 20 Relaxing the range-for loop customization point finding rules por
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진화 손
6 visualizações2 slides
C++ 20 Relaxing the structured bindings customization point finding rules por
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진화 손
7 visualizações4 slides
C++20 explicit(bool) por
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)진화 손
6 visualizações3 slides
C++20 std::map::contains por
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains진화 손
5 visualizações3 slides
C++20 Comparing unordered containers por
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers진화 손
8 visualizações6 slides
C++20 Attributes [[likely]] and [[unlikely]] por
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]진화 손
21 visualizações4 slides

Mais de 진화 손(20)

C++ 20 Relaxing the range-for loop customization point finding rules por 진화 손
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
진화 손6 visualizações
C++ 20 Relaxing the structured bindings customization point finding rules por 진화 손
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
진화 손7 visualizações
C++20 explicit(bool) por 진화 손
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)
진화 손6 visualizações
C++20 std::map::contains por 진화 손
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains
진화 손5 visualizações
C++20 Comparing unordered containers por 진화 손
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers
진화 손8 visualizações
C++20 Attributes [[likely]] and [[unlikely]] por 진화 손
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]
진화 손21 visualizações
C++ 20 Lambdas in unevaluated contexts por 진화 손
C++ 20 Lambdas in unevaluated contextsC++ 20 Lambdas in unevaluated contexts
C++ 20 Lambdas in unevaluated contexts
진화 손4 visualizações
C++20 Library support for operator<=> <compare> por 진화 손
C++20 Library support for operator<=> <compare>C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>
진화 손2 visualizações
C++20 const mismatch with defaulted copy constructor por 진화 손
C++20 const mismatch with defaulted copy constructorC++20 const mismatch with defaulted copy constructor
C++20 const mismatch with defaulted copy constructor
진화 손5 visualizações
C++20 Atomic std::shared_ptr and std::weak_ptr por 진화 손
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
진화 손11 visualizações
C++20 Default member initializers for bit-fields por 진화 손
C++20 Default member initializers for bit-fieldsC++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fields
진화 손10 visualizações
C++ 20 constexpr for algorithm and utility por 진화 손
C++ 20 constexpr for  algorithm and utilityC++ 20 constexpr for  algorithm and utility
C++ 20 constexpr for algorithm and utility
진화 손8 visualizações
C++17 init-statements for if and switch por 진화 손
C++17 init-statements for if and switchC++17 init-statements for if and switch
C++17 init-statements for if and switch
진화 손9 visualizações
C++17 Aggregate classes with base classes por 진화 손
C++17 Aggregate classes with base classesC++17 Aggregate classes with base classes
C++17 Aggregate classes with base classes
진화 손8 visualizações
C++17 std::byte por 진화 손
C++17 std::byteC++17 std::byte
C++17 std::byte
진화 손108 visualizações
C++17 not_fn por 진화 손
C++17 not_fnC++17 not_fn
C++17 not_fn
진화 손14 visualizações
C++17 return type of emplace_ functions of some containers changed from void ... por 진화 손
C++17 return type of emplace_ functions of some containers changed from void ...C++17 return type of emplace_ functions of some containers changed from void ...
C++17 return type of emplace_ functions of some containers changed from void ...
진화 손4 visualizações
C++17 [[fallthrough]] attribute por 진화 손
C++17 [[fallthrough]] attributeC++17 [[fallthrough]] attribute
C++17 [[fallthrough]] attribute
진화 손7 visualizações
C++ 17 __has_include in preprocessor conditionals por 진화 손
C++ 17 __has_include in preprocessor conditionalsC++ 17 __has_include in preprocessor conditionals
C++ 17 __has_include in preprocessor conditionals
진화 손5 visualizações
C++17 Folding expressions por 진화 손
C++17 Folding expressionsC++17 Folding expressions
C++17 Folding expressions
진화 손3 visualizações

C++17 Dynamic memory allocation for over-aligned data

  • 1. Dynamic memory allocation for over-aligned data https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html
  • 2. 제목 번역 C++ 11 에 alignas 키워드가 추가 됨 이 alignas로 설정한 크기가 __STDCPP_DEFAULT_NEW_ALIGNMENT__ 를 넘는 클래스를 동적할당 할 경우 프로그래머가 기대한 대로 동작하지 않는 문제가 있었다고 함 __STDCPP_DEFAULT_NEW_ALIGNMENT__ : 컴퓨터마다 다르니 확인 필요 회사 컴은 8. 집 컴은 16
  • 3. std::align_val_t new, delete 오버로딩 함수를 추가하기 위한 키워드 선언 https://en.cppreference.com/w/cpp/memory/new/align_val_t
  • 4. 새로운 new, delete 추가 알아서 오버로딩 되기 때문에 코드 사용법이 변경되지는 않는다 align 사이즈가 __STDCPP_DEFAULT_NEW_ ALIGNMENT__ 를 넘으면 operator new(sizeof(T), std::align_val_t(alignof(T))) 이렇게 변환이 되어서 오버로딩되는 거 같음... https://en.cppreference.com/w/cpp/language/new https://en.cppreference.com/w/cpp/memory/new/operato r_new
  • 5. Visual Studio VS 2017 에서 부터 사용가능 옛날 버전에는 /Zc:alignedNew 키워드를 사용해야 해당 기능을 사용할 수 있었으나 최신 버전에서는 기본으로 포함되어 있음 https://learn.microsoft.com/ko-kr/cpp/build/reference/zc-alignednew?view=msvc-170