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 <iostream> | |
| template <typename type, typename tag = type> | |
| struct inline_variable { | |
| static type &get(const type &initial_value) { | |
| static type _{initial_value}; | |
| return _; | |
| } | |
| }; |
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
| #!/bin/bash | |
| clang++ -Wall impl.cpp sub.cpp -o impl.a -std=c++11 | |
| ./impl.a |
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 <cmath> | |
| namespace bbb { | |
| namespace autodiff { | |
| template <typename type> | |
| struct dual { | |
| inline static dual make(type x) { return dual(x); }; | |
| inline static dual scalar(type x) { return dual(x, 0.0); }; | |
| constexpr dual(type x, type dx = type(1.0)) noexcept |
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
| set i to 1 | |
| repeat while true | |
| say {"羊が", i, "匹"} as string using "Kyoko" | |
| set i to i + 1 | |
| delay 1 | |
| end repeat |
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
| defmodule Brainfuck do | |
| @seek_next ?> | |
| @seek_prev ?< | |
| @inc_head ?+ | |
| @dec_head ?- | |
| @print_head ?. | |
| @read_input ?, | |
| @loop_begin ?[ | |
| @loop_end ?] | |
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 <iostream> | |
| int f(int x) { | |
| std::cout << "true f" << std::endl; | |
| return 0; | |
| } | |
| namespace bbb { | |
| struct function_is_not_exist {}; | |
| function_is_not_exist f(...) { return {}; }; |
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
| #!/bin/bash | |
| clang++ -c -std=c++11 -stdlib=libc++ main.cpp | |
| clang++ -c -std=c++11 -stdlib=libc++ sub.cpp | |
| clang++ main.o sub.o -o main |
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
| namespace bbb { | |
| template <typename type> | |
| struct is_null_pointer : std::false_type {}; | |
| template <typename type> | |
| using is_null_pointer_t : get_type<is_null_pointer<type>>; | |
| template <> | |
| struct is_null_pointer<std::nullptr_t> : std::true_type {}; | |
| template <typename ...> |
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 <bbb/pipe.hpp> | |
| #include <iostream> | |
| int main(int argc, char *argv[]) { | |
| std::string str = "a/b/cdcd/ezzzf/ghi/azzz/czzzd/ef"; | |
| auto res = str | |
| | bbb::replace("zzz", "Z") // "a/b/cdcd/eZf/ghi/aZ/cZd/ef" | |
| | bbb::split("/") // {"a", "b", "cdcd", "eZf", "ghi", "aZ", "cZd", "ef"} | |
| | bbb::filter([](std::string str) { return str.length() < 3; }) // {"a", "b", "aZ", "ef"} |
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
| function fun(org = function(...args) { throw new Error("overload failed", args.map(a => typeof a)); }, ... others) { | |
| const overload_functions = {}; | |
| if(others.length) { | |
| overload_functions[others.map(a => a.constructor.name)] = org; | |
| org = function(...args) { throw new Error("overload failed", args.map(a => typeof a)); }; | |
| } | |
| const f = function(... args) { | |
| return ((overload_functions[args.map(a => a.constructor.name)] || org).bind(this))(... args); | |
| } | |
| f.overload = function(overloading_function, ...args) { |