Skip to content

Instantly share code, notes, and snippets.

View LusainKim's full-sized avatar

Lusain_Kim LusainKim

View GitHub Profile
@LusainKim
LusainKim / reflection_manager.cpp
Created May 30, 2019 03:19
Implemented a container wrapper class that type and value corresponded 1: 1, and all elements are base to Ty, used C++14 (working)
#include <memory>
#include <utility>
#include <typeinfo>
#include <typeindex>
#include <unordered_map>
template<typename Ty, typename KeyTy = std::type_index, typename ValTy = std::unique_ptr<Ty>>
class reflection_manager
@LusainKim
LusainKim / type_map.cpp
Last active May 30, 2019 02:30
Implemented a container wrapper class that type and value corresponded 1: 1, used C++17
#include <any>
#include <utility>
#include <typeinfo>
#include <typeindex>
#include <unordered_map>
class type_map
{
public:
using This = type_map;
@LusainKim
LusainKim / group.cpp
Last active August 27, 2018 07:58
A code that compares multiple cases to a single target.
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
namespace group_compare
{
@LusainKim
LusainKim / GetIPStringByRegex.cpp
Last active May 30, 2017 08:43
문자열로 입력받은 IP 주소가 유효한지 정규식을 사용하여 검사하는 코드입니다.
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main()
{
regex rg { "^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$" };
@LusainKim
LusainKim / GetFiles.cpp
Created January 21, 2017 07:07
콘솔에서 지정한 디렉터리에 위치한 모든 파일의 목록을 반환하는 예제입니다.
////////////////////////////////////////////////////////////////////////////////////
// Get Files
////////////////////////////////////////////////////////////////////////////////////
// summary : 파일 경로의 목록을 vector 형식으로 반환합니다.
// remark : 하위 목록이라고 별도의 목록에 담기지 않습니다.
// author : @Lusain_Kim
////////////////////////////////////////////////////////////////////////////////////
// 유니코드 전용 샘플 코드
#ifndef UNICODE
@LusainKim
LusainKim / BuildArray.cpp
Created December 2, 2016 12:32
Build Array
#include <iostream>
#include <array>
using namespace std;
template<typename Ty, typename... Args>
constexpr auto BuildArray(Args&&... args) noexcept { return array<Ty, sizeof...(args)>{ args... }; }
template <typename Ty, size_t N> using TyArr = Ty[N];
@LusainKim
LusainKim / sample.cpp
Last active November 21, 2016 13:56
fstream example
#include <iostream>
#include <fstream>
using namespace std;
struct Data
{
char name[20];
int dummy;
};
@LusainKim
LusainKim / FixValue.h
Last active November 23, 2016 14:36
FixValue
#ifndef __FIXVALUE__
#define __FIXVALUE__
#include <string>
#ifdef UNICODE
using FixValueString = std::wstring;
#define to_FixValueString std::to_wstring
#else
using FixValueString = std::string;
@LusainKim
LusainKim / .editorconfig
Last active August 27, 2018 07:57
.editorconfig
root = true
[*]
indent_style = tab
indent_size = 4
[*.{c,cpp,h,hpp}]
charset = utf-8
indent_style = tab
indent_size = 4
@LusainKim
LusainKim / enumTest.cpp
Last active July 13, 2016 07:33
enum class example
#include <iostream>
namespace EnumFunc {
template<typename Enum> // Enum class의 선언형을 알려주어 인자와 대응하는 값을 반환하는 함수입니다.
inline constexpr auto GetEnumValueByType(Enum enumerator) noexcept // enum class E : int { a,b,c }; 일 때,
{ // auto data = GetEnumValueByType(E::a);
return static_cast<std::underlying_type_t<Enum>>(enumerator); // data의 형식은 int 이고, 값은 0 입니다.
}