프로그래밍
-
러스트를 배워보는 중프로그래밍 2023. 9. 10. 21:44
얼마 전부터 Rust를 이제 막 배워보고 있어요. 하루에 몇 분 씩 시간 내서요. 아래 Rust 공식문서로 학습하고 있고, 이제 막 struct까지 했어요. Using Structs to Structure Related Data - The Rust Programming Language (rust-lang.org) Using Structs to Structure Related Data - The Rust Programming Language A struct, or structure, is a custom data type that lets you package together and name multiple related values that make up a meaningful group. If you’..
-
간단한 디펜던시 인젝션(DI) 구현프로그래밍/기록, 개념, 용어 2022. 11. 14. 14:21
Singleton, Transient, Scoped 같은 라이프타임은 제외하고, 어떻게 생성자가 요구하는 인자들을 순서대로 전달하는지에 대해 초점을 맞췄습니다. 아래에 HelloService가 있습니다. HelloService 클래스는 생성자에서 string과 List을 파라미터로 가지고 있습니다. 우리는 이 HelloService를 생성할 때, 외부에서 지정한 인자들을 주입하는 것이 목적입니다. class HelloService { private string _header; private List _contents; public HelloService(string header, List contents) { _header = header; _contents = contents; } public void..
-
boost/asio deprecated 1.69.0프로그래밍/c++ - boost::asio 2019. 3. 11. 04:44
boost::asio가 c++ 표준에 들어가게 되서 그런지 변경 사항들이 많다.호환성을 위해 더이상 더이상 사용되지 않는 코드들이 여전히 남아있지만,전처리기에 BOOST_ASIO_NO_DEPRECATED를 지정하면 더이상 사용되지 않는 코드들이 비활성화 된다. io_service가 io_context로 이름 변경io_context::dispatch가 dispatch 로 대체 됨io_context::post가 post 로 대체 됨io_context::strand::wrap이 bind_execuator 로 대체 됨io_context::get_io_context(), io_context::get_io_service()가 context() 함수로 이름 변경.io_context::strand::get_io_con..
-
boost/asio simple periodic timer프로그래밍/코드 조각 2019. 3. 4. 12:28
#include #include #include class PeriodicTimerExample{public: PeriodicTimerExample() : timer{ctx} { } void run() { tick(); ctx.run(); } private: void tick() { using namespace std; timer.expires_after(3s); timer.async_wait([this](const auto & err) { cout
-
c++, istream으로 읽은 개수 반환 gcount프로그래밍/코드 조각 2019. 1. 19. 12:21
readsome이 아니다. auto MakeHash(std::istream& is){ std::array fileHash; SHA256_CTX ctx; SHA256_Init(&ctx); char buf[512]{ 0, }; while (is.good()) { is.read(buf, sizeof(buf)); const int cnt = is.gcount(); SHA256_Update(&ctx, buf, cnt); } SHA256_Final(fileHash.data(), &ctx); return fileHash;}gcount는 마지막으로 읽어난 엘리먼트의 개수를 반환한다.