This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // str_wrapper | |
| class str_wrapper{ | |
| public: | |
| inline str_wrapper() : ptr(nullptr){} | |
| inline str_wrapper(const std::string &str) : ptr(get_ptr(str)){} | |
| inline str_wrapper(const char *str) : ptr(get_ptr(str)){} | |
| inline str_wrapper &operator =(const std::string &other){ | |
| ptr = get_ptr(other); | |
| return *this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct str_wrapper_less : public std::binary_function<str_wrapper, str_wrapper, bool>{ | |
| inline bool operator ()(const str_wrapper &lhs, const str_wrapper &rhs) const{ | |
| return *lhs.ptr < *rhs.ptr; | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // x_prime^(num / den) = a in N | |
| // OR | |
| // x_prime | |
| #include <cmath> | |
| #include <cstdint> | |
| std::int64_t factorize_nd(std::int64_t x_prime, std::int64_t num, std::int64_t den){ | |
| std::int64_t x = x_prime; | |
| std::int64_t t = 0, u = 1, tt = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <typeindex> | |
| template<class T> | |
| constexpr std::size_t get(){ | |
| return std::type_index(typeid(T)).hash_code(); | |
| } | |
| class a{}; | |
| class b{}; | |
| class c{}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdint> | |
| template<typename T> | |
| constexpr std::uint64_t get(){ | |
| struct dummy_struct{ | |
| static void f(){} | |
| }; | |
| return reinterpret_cast<std::uint64_t>(dummy_struct::f); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdint> | |
| template<typename T> | |
| constexpr std::uint64_t get(){ | |
| return reinterpret_cast<std::uint64_t>(&get<T>); | |
| } | |
| class a{}; | |
| class b{}; | |
| class c{}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| main.cpp:15:26: error: constexpr variable 'id_a' must be initialized by a | |
| constant expression | |
| constexpr std::uint64_t id_a = get<a>(), id_b = get<b>(), id_c ... | |
| ^ ~~~~~~~~ | |
| main.cpp:5:9: note: reinterpret_cast is not allowed in a constant expression | |
| return reinterpret_cast<std::uint64_t>(&get<T>); | |
| ^ | |
| main.cpp:15:33: note: in call to 'get()' | |
| constexpr std::uint64_t id_a = get<a>(), id_b = get<b>(), id_c ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| au FileType cpp,cc,cxx,h,hpp,hxx call <SID>KatatsumuriCompleteInit() | |
| autocmd FileType cpp,cc,cxx,h,hpp,hxx setlocal completefunc=KatatsumuriComplete | |
| autocmd FileType cpp,cc,cxx,h,hpp,hxx setlocal omnifunc=KatatsumuriComplete | |
| let s:katatsumuri_complete_list = [] | |
| function! s:KatatsumuriCompleteInit() | |
| if !exists('g:katatsumuri_complete_binary') | |
| let g:katatsumuri_complete_binary = 'katatsumuri_complete' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <token_desc> token{ | |
| <right>{ unary_minus; } | |
| <left>{ | |
| ast, sla; | |
| pls, mns; | |
| } | |
| l_paren, r_paren; | |
| id<int>; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Valueの型はDSLに入力するファイルに記入されている | |
| -- ここでは単純化のためにInt | |
| type Value = Int | |
| defaultValue = 0 | |
| -- DSLから自動生成されたデータコンストラクタ | |
| data Token = End | UMns | Ast | Sla | Pls | Mns | LParen | RParen | Id | |
| deriving (Enum, Eq, Ord) | |
| data StackFrame = StackFrame { |