'Programming/C++ STL'에 해당되는 글 72건

  1. 2025.02.20 cpp std::to_string(int)
  2. 2025.02.06 cpp string 끝에 한글자 지우기
  3. 2025.02.06 cpp stoi (atoi)
  4. 2025.02.05 std::string:npos
  5. 2025.01.31 std::istringstream
  6. 2025.01.16 cpp destructor = default
  7. 2024.11.28 RAII (Resource Acquisition Is Initialization)
  8. 2024.11.22 cpp lambda
  9. 2023.02.09 cpp static_cast<type>
  10. 2021.11.10 ::open()
Programming/C++ STL2025. 2. 20. 12:32

자동 형변환(?)은 지원안하는지

문자열 끝에 "blah blah : " + value 하니 에러가 발생해서 찾아보니

std::to_string() 이라는 착한 녀석이 존재함을 발견!

 

[링크 : https://en.cppreference.com/w/cpp/string/basic_string/to_string]

[링크 : https://developer-cat.tistory.com/19]

'Programming > C++ STL' 카테고리의 다른 글

cpp string 끝에 한글자 지우기  (0) 2025.02.06
cpp stoi (atoi)  (0) 2025.02.06
std::string:npos  (0) 2025.02.05
std::istringstream  (0) 2025.01.31
cpp destructor = default  (0) 2025.01.16
Posted by 구차니
Programming/C++ STL2025. 2. 6. 12:36

'Programming > C++ STL' 카테고리의 다른 글

cpp std::to_string(int)  (0) 2025.02.20
cpp stoi (atoi)  (0) 2025.02.06
std::string:npos  (0) 2025.02.05
std::istringstream  (0) 2025.01.31
cpp destructor = default  (0) 2025.01.16
Posted by 구차니
Programming/C++ STL2025. 2. 6. 12:11

std::string() 객체를 숫자로 바꾸어 주는 함수

c의 atoi 처럼 stoi stof 등이 존재한다.

 

[링크 : https://blockdmask.tistory.com/333]

[링크 : https://en.cppreference.com/w/cpp/string/basic_string/stol]

'Programming > C++ STL' 카테고리의 다른 글

cpp std::to_string(int)  (0) 2025.02.20
cpp string 끝에 한글자 지우기  (0) 2025.02.06
std::string:npos  (0) 2025.02.05
std::istringstream  (0) 2025.01.31
cpp destructor = default  (0) 2025.01.16
Posted by 구차니
Programming/C++ STL2025. 2. 5. 18:03

문자열의 끝까지를 의미하는 unsigned -1 값

std::string::find() 시에도 찾지 못하면 npos 값으로 -1을 리턴한다.

 

[링크 : https://cplusplus.com/reference/string/string/npos/]

'Programming > C++ STL' 카테고리의 다른 글

cpp string 끝에 한글자 지우기  (0) 2025.02.06
cpp stoi (atoi)  (0) 2025.02.06
std::istringstream  (0) 2025.01.31
cpp destructor = default  (0) 2025.01.16
RAII (Resource Acquisition Is Initialization)  (0) 2024.11.28
Posted by 구차니
Programming/C++ STL2025. 1. 31. 17:16

간단하게 요약하면 공백으로 구분하는 토크나이저

[링크 : https://myprivatestudy.tistory.com/48]

 

[링크 : https://en.cppreference.com/w/cpp/io/basic_istringstream]

[링크 : https://cplusplus.com/reference/sstream/istringstream/]

 

아래를 inlcude 안해주면 먼가 희한한 에러가 발생한다.

#include <sstream>

[링크 : https://stackoverflow.com/questions/10882376/stdstringstream-does-not-name-a-type-global]

'Programming > C++ STL' 카테고리의 다른 글

cpp stoi (atoi)  (0) 2025.02.06
std::string:npos  (0) 2025.02.05
cpp destructor = default  (0) 2025.01.16
RAII (Resource Acquisition Is Initialization)  (0) 2024.11.28
cpp lambda  (0) 2024.11.22
Posted by 구차니
Programming/C++ STL2025. 1. 16. 15:39

 

[링크 : https://stackoverflow.com/questions/13576055/how-is-default-different-from-for-default-constructor-and-destructor]

[링크 : https://andreasfertig.com/blog/2022/03/a-destructor-default-and-the-move-operations/]

 

c++11 에 추가된 키워드 인 듯. 꽤 오래되긴 했네..

다만 생성자나 소멸자에 사용할 경우 객체 생성보다는 기본 객체를 포인터로 연결하는 얕은 복사를 사용한다는 의미일 듯.

반대는 delete 키워드로 기본 지정을 막을 수 있는 듯.

[링크 : https://woo-dev.tistory.com/100]

'Programming > C++ STL' 카테고리의 다른 글

std::string:npos  (0) 2025.02.05
std::istringstream  (0) 2025.01.31
RAII (Resource Acquisition Is Initialization)  (0) 2024.11.28
cpp lambda  (0) 2024.11.22
cpp static_cast<type>  (0) 2023.02.09
Posted by 구차니
Programming/C++ STL2024. 11. 28. 08:25

'Programming > C++ STL' 카테고리의 다른 글

std::istringstream  (0) 2025.01.31
cpp destructor = default  (0) 2025.01.16
cpp lambda  (0) 2024.11.22
cpp static_cast<type>  (0) 2023.02.09
::open()  (0) 2021.11.10
Posted by 구차니
Programming/C++ STL2024. 11. 22. 15:56

왜 갑자기 배열이 나와 하면서

먼가 희한한 문법이 보이길래 찾아보니 이게 c++ 에서의 람다라고..

도대체 람다는 왜 쓰는걸까?

#include <algorithm>
#include <cmath>

void abssort(float* x, unsigned n) {
    std::sort(x, x + n,
        // Lambda expression begins
        [](float a, float b) {
            return (std::abs(a) < std::abs(b));
        } // end of lambda expression
    );
}

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/lambda-expressions-in-cpp?view=msvc-170]

 

+

2025.01.31

리턴타입도 있는게 당연한긴 한데.. 없으면 cpp 이니까 return 타입을 알아서 넣어주나?

[my_mod] (int v_) -> int { return v_ % my_mod; }

[링크 : https://modoocode.com/196]

 

mutable throw() 라는걸 발견.. 이건 또 머냐

1. capture 절 (C++ 사양의 람다 소개자 라고도 함)
2. 매개 변수 목록 선택 사항입니다. (람다 선언자라고도 함)
3. 변경 가능한 사양 선택 사항입니다.
4. exception-specification 선택 사항입니다.
5. 후행 반환 형식 선택 사항입니다.
6. 람다 본문입니다.

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/lambda-expressions-in-cpp?view=msvc-170]

'Programming > C++ STL' 카테고리의 다른 글

cpp destructor = default  (0) 2025.01.16
RAII (Resource Acquisition Is Initialization)  (0) 2024.11.28
cpp static_cast<type>  (0) 2023.02.09
::open()  (0) 2021.11.10
vector 값 비우기  (0) 2021.10.02
Posted by 구차니
Programming/C++ STL2023. 2. 9. 11:31

cpp랑은 안친하다 보니.. 그나저나 템플릿을 저런식으로도 쓰나 싶긴 한데..

 

static_cast, dynamic_cast, reinterpret_cast, const_cast

[링크 : https://blockdmask.tistory.com/236]

[링크 : https://hwan-shell.tistory.com/211]

 

표준 C++에서는 변환의 안전성을 보장하기 위해 런타임 형식 검사가 수행되지 않습니다. C++/CX에서는 컴파일 시간 및 런타임 검사가 수행됩니다. 

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/static-cast-operator?view=msvc-170]

 

캐스트 연산자에는 C++ 언어 전용 연산자가 몇 가지 있습니다. 이 연산자는 예전 스타일의 C 언어 캐스트에 있는 일부 모호함과 위험성을 제거하는 데 목적이 있습니다. 그 종류는 다음과 같습니다.
  • Dynamic_cast 다형 형식의 변환에 사용됩니다.
  • Static_cast 비포형 형식의 변환에 사용됩니다.
  • const_cast , volatile __unaligned 특성을 제거하는 const데 사용됩니다.
  • reinterpret_cast 비트의 간단한 재해석에 사용됩니다.
  • safe_cast C++/CLI에서 확인 가능한 MSIL을 생성하는 데 사용됩니다.

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/casting-operators?view=msvc-170]

'Programming > C++ STL' 카테고리의 다른 글

RAII (Resource Acquisition Is Initialization)  (0) 2024.11.28
cpp lambda  (0) 2024.11.22
::open()  (0) 2021.11.10
vector 값 비우기  (0) 2021.10.02
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
Posted by 구차니
Programming/C++ STL2021. 11. 10. 18:10

QT에서 QSeialPort.open() 이 있고

QSerialPort를 상속받은 클래스에서

open()을 하면 자동으로 부모인 QSeialPort.open() 를 호출하게 되는데

CPP가 아닌 C의 fnctl.h의 open()을 열고 싶으면

::open()을 하면 되...나?

 

[링크 : https://stackoverflow.com/questions/10772169/calling-same-name-function]

'Programming > C++ STL' 카테고리의 다른 글

cpp lambda  (0) 2024.11.22
cpp static_cast<type>  (0) 2023.02.09
vector 값 비우기  (0) 2021.10.02
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
Posted by 구차니