Home [C++] 참고할만한 링크 목록
Post
Cancel

[C++] 참고할만한 링크 목록

Why does C++ allow unnamed function parameters?

  • TMP에서 특정한 함수로 유도하기 위해.. 사용하지 않는 파라미터에 이름을 붙이지 않음
    • 템플릿 특수화/ 부분특수화

Pointer To Class Data Member

  • 클래스명::*{name}
  • 클래스변수.*name or 클래스변수->*name으로 접근
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
#include <iostream>

class bowl {
public:
    int apples;
    int oranges;
};

int count_fruit(bowl * begin, bowl * end, int bowl::*fruit)
{
    int count = 0;
    for (bowl * iterator = begin; iterator != end; ++ iterator)
        count += iterator->*fruit;
    return count;
}

int main()
{
    bowl bowls[2] = {
        { 1, 2 },
        { 3, 5 }
    };
    std::cout << "I have " << count_fruit(bowls, bowls + 2, & bowl::apples) << " apples\n";
    std::cout << "I have " << count_fruit(bowls, bowls + 2, & bowl::oranges) << " oranges\n";
    return 0;
}

SOA

Array of structure of fixed-size arrays

  • The demo shows that, depending on the use case, AoS or SoA is superior, and that AoSoA may be a good compromise
This post is licensed under CC BY 4.0 by the author.

[C++] emc++ 01: Type Deduction(auto 등)

[ostep] 프로세스 API