출처 C++11 이상 가능. // 템플릿의 default 값에 함수 포인터 타입을 정의 template<typename T, typename Func = T(*)(T, T)> constexpr T calc(T a, T b, Func func){ return func(a, b); } template<typename T> constexpr T plus(T a, T b){ return...
더 읽기
원문 호출 예 hoge.h #pragma once struct Hoge { int _data1; unsigned char _data2[1]; }; main.cc #include "uniqueptr1.h" #include "uniqueptr2.h" #include "uniqueptr3.h" int main() { auto p1 = CreateHoge1(100); auto p2 = CreateHoge2(100); auto p3 = CreateHoge3(100); return 0; }...
더 읽기
최근 C++ 표준 라이브러리와 Boost의 작은 유행으로 태그 디스패치의 태그를 사용자에게 명시적으로 지정하게 함으로써 함수 오버로드를 손쉽게 하는 방법이 몇몇 곳에서 나타나고 있다. // Boost.Container의 vector의 예 // 태그 정의 struct default_init_t {}; constexpr default_init_t default_init {}; // vector 생성자...
더 읽기
출처 라이브러리 출력 이름을 MyLibrary_x86_Debug.lib 라고 하고 싶다. 또 아래처럼 디렉토리 구성으로 하고 싶다. MyLibrary MyLibrary.sln MyLibrary MyLibrary.vcxproj lib MyLibrary_x86_Debug.lib MyLibrary_x64_Debug.lib MyLibrary_x86_Release.lib MyLibrary_x64_Release.lib 으 프로젝트는 라이브러리를 만드는 것이다. 구성 프로퍼티 -> 일반 출력 디렉토리를 바꾼다. $(SolitionDir)..\lib\ 타겟 이름을 바꾼다. $(SolutionName)_$(Platform)_$(Configuration)...
더 읽기
출처 class Employer{ float time_for_game_;//게임 시간 float time_for_anime_;//애니메이션의 시간 float time_for_family_;//가족과의 시간 public: float time_for_work_;//일의 시간 // 인사 template<class Rank> void greet(Rank target){ std;cout<<"hello"<<std::endl; } }; //사장에게만은 인사 말고 휴가를 조르다 template<> void Employer::greet(President target){ std;cout<<"holiday please"<<std::endl; } int main()...
더 읽기
몇 년전에 웹에 공개된 글을 보고 정리했던 글이다.
더 읽기
출처 커널 파라메터 설명은 아래 링크에서 참고 linux/Documentation/sysctl/ 예를 들어 net 계열의 파라메터 설명을 보고 싶다는 아래에서 확인한다. linux/Documentation/sysctl/net.txt TCP 서버용 tuning 기본 # 항구적 설정 $ vi /etc/sysctl.conf $ sysctl -p kernel # 공유 메모리의 최대 사이즈. 서버 탑재...
더 읽기
출처 #include <iostream> #include <memory> using ub4 = unsigned int; // 외부에 공개해서 이용하는 클래스 class A { public: // 클래스 밖에서 using을 사용하고 싶으므로 public 로 한다. class impl; private: std::unique_ptr<impl> pim; public: A(); ~A(); public: void func_call( ub4...
더 읽기
출처 C++11에서 새로 추가됨 int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, intmax_t, uintmax_t, intptr_t, uintptr_t 아래 헤더 파일을 추가해야 한다 #include <cstdint> std::int8_t...
더 읽기
출처 Visual C++ 전용 키워드 이다. __if_exists ( identifier ) { statements }; identifier에 전달한 식별자가 존재한다면 statements가 실행된다. 부정형으로 __if_not_exists가 있다. 컴파일 타임 때 실행. template<typename T> class X : public T { public: void Dump() { __if_exists(T::Dump) {...
더 읽기