Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags more
Archives
Today
Total
관리 메뉴

Pure Software Engineer :)

Effective Modern C++ 본문

Software Engineering/Programming

Effective Modern C++

HelloJaewon 2014. 12. 5. 11:44

C++은 이제 더이상 예전의 C++이 아니다.
C++11 표준이 발표되고 C++14도 곧 나올것같은 상황에서 계속 공부를 하지 않으면
이게 C++ 코드나 맞나? 싶을 정도로 새롭게 변화하고 있다

Effective C++에 이어 C++11, C++14를 위한 Effective Modern C++이 최근 출간되었다.
우선 항목부터 정리해보고 조금씩 읽어 보자.

1. Deducing Types

  • Item 1: Understanding template type deduction
  • Item 2: Understanding auto type deduction
  • Item 3: Understanding decltype
  • Item 4: Know how to view deduced types

2. auto

  • Item 5: Prefer auto to explicit type declarations
  • Item 6: Use the explicitly typed initializer idiom when auto deduces undesired types

3. Moving to Modern C++

  • Item 7: Distinguish between () and {} when creating objects
  • Item 8: Prefer nullptr to 0 and NULL
  • Item 9: Prefer alias declarations to typedefs
  • Item 10: Prefer scoped enums to unscoped enums
  • Item 11: Prefer deleted functions to private undefined ones
  • Item 12: Declare overriding functions override
  • Item 13: Prefer const_iterators to iterators
  • Item 14: Declare function noexcept if they won't emit exceptions
  • Item 15: Use constexpr whenever possible
  • Item 16: Make const member functions thread safe
  • Item 17: Understand special member function generation

4. Smart Pointers

  • Item 18: Use std::unique_ptr for exclusive-ownership resource management
  • Item 19: Use std::shared_ptr for shared-ownership resource management
  • Item 20: Use std::weak_ptr for std::shared_ptr-like pointers that can dangle
  • Item 21: Prefer std::make_unique and std::make_shared to direct use of new
  • Item 22: When using the Pimpl Idiom, define special member functions in the implementation file

5. Rvalue References, Move Semantics, and Perfect Forwarding

  • Item 23: Understanding std::move and std::forward
  • Item 24: Distinguish universal references from rvalue references
  • Item 25: Use std::move on rvalue references, std::forward on universal references
  • Item 26: Avoid overloading on universal references
  • Item 27: Familiarize yourself with alternative to overloading on universal references
  • Item 28: Understand reference collapsing
  • Item 29: Assume that move operations are not present, not cheap, and not used
  • Item 30: Familiarize yourself with perfect forwarding failure cases

6. Lambda Expression

  • Item 31: Avoid default capture modes
  • Item 32: Use init capture to move objects into closures
  • Item 33: Use decltype on auto&& parameters to std::forward them

7. The concurrency API

  • Item 35: Prefer task-based programming to thread-based
  • Item 36: Specify std::launch::async if asynchronicity is essential
  • Item 37: Make std::threads unjoinable on all paths
  • Item 38: Be aware of varying thread handle destructor behavior
  • Item 39: Consider void futures for one-shot event communication
  • Item 40: Use std::atomic for concurrency, volatile for special memory

8. Twaks

  • Item 41: Consider pass by value for copyable parameters that are cheap to move and always copied
  • Item 42: Consider emplacement instead of insertion