char 1 bytes unsigned char 1 bytes ----------------------------------------------- short 2 bytes unsigned short 2 bytes ----------------------------------------------- int 4 bytes unsigned int 4 bytes ----------------------------------------------- long 4 bytes unsigned long 4 bytes ----------------------------------------------- long int 4 bytes unsigned long int 4 bytes ----------------------------------------------- long long 8 bytes unsigned long long 8 bytes ----------------------------------------------- long long int 8 bytes unsigned long long int 8 bytes ----------------------------------------------- int8_t 1 bytes uint8_t 1 bytes ----------------------------------------------- int16_t 2 bytes uint16_t 2 bytes ----------------------------------------------- int32_t 4 bytes uint32_t 4 bytes ----------------------------------------------- int64_t 8 bytes uint64_t 8 bytes
char 1 bytes unsigned char 1 bytes ----------------------------------------------- short 2 bytes unsigned short 2 bytes ----------------------------------------------- int 4 bytes unsigned int 4 bytes ----------------------------------------------- long 8 bytes unsigned long 8 bytes ----------------------------------------------- long int 8 bytes unsigned long int 8 bytes ----------------------------------------------- long long 8 bytes unsigned long long 8 bytes ----------------------------------------------- long long int 8 bytes unsigned long long int 8 bytes ----------------------------------------------- int8_t 1 bytes uint8_t 1 bytes ----------------------------------------------- int16_t 2 bytes uint16_t 2 bytes ----------------------------------------------- int32_t 4 bytes uint32_t 4 bytes ----------------------------------------------- int64_t 8 bytes uint64_t 8 bytes
#include <mutex>
std::mutex mutex1;
/////////// Lock 이 걸린 상태에서 다시 lock 호출
void deadlock_1() {
std::lock_guard<std::mutex> lockGuard(mutex1);
deadlock_1_1();
}
void deadlock_1_1() {
std::lock_guard<std::mutex> lockGuard(mutex1); // 걸려 있는 lock에 대해 다시 lock 시도
}
////////// Lock 이 걸린 상태에서 돌고 돌아 다시 lock 호출, 많이 돌고 돌다 lock 이 걸리면 ...
void deadlock_2() {
std::lock_guard<std::mutex> lockGuard(mutex1);
deadlock_2_1();
}
void deadlock_2_1() {
deadlock_2(); // 재귀 호출로 다시 lock 시도
}
std::array<int, 4> arr = { 1, 2, 3, 4};
for (int i : arr) {
std::cout << i << std::endl;
}
int carr[4] = { 5, 6, 7, 8 };
for (int i : carr) {
std::cout << i << std::endl;
}
initializer list include <initializer_list> 클래스 템플릿, 타입 세이프
int a = makeSum({ 1, 2, 3 });
int b = makeSum({ 10, 20, 30, 40, 50, 60 });
// int c = makeSum({ 1, 2, 3.0 }); // ERROR
cout << "a = " << a << ", b = " << b << endl;