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 December 2, 2025 23:12
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 ์ž…๋‹ˆ๋‹ค.
}