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 <stdexcept> | |
| #include <utility> | |
| #include <cassert> | |
| #if 0 | |
| #define NORETURN [[noreturn]] | |
| #else | |
| #define NORETURN | |
| #endif |
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 <memory> | |
| #include <string> | |
| struct hoge { | |
| explicit hoge(std::string name, int value); | |
| ~hoge(); | |
| hoge(hoge&&) = delete; | |
| void operator=(hoge&&) = delete; | |
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
| #ifndef INCLUDED_DLFCN_HPP_ | |
| #define INCLUDED_DLFCN_HPP_ | |
| #include <dlfcn.h> | |
| #include <cassert> | |
| #include <stdexcept> | |
| namespace dlfcn { | |
| struct dlfcn_error : std::runtime_error { |
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 "hoge.hpp" | |
| #include <iostream> | |
| struct Hoge::Impl { | |
| int member; | |
| }; | |
| void Hoge::ImplDisposer::operator()(Hoge::Impl* p) const { | |
| delete p; |
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 <utility> | |
| template<class FwdIter, class Eq, class Merge> | |
| inline FwdIter unique_by(FwdIter first, FwdIter last, Eq eq, Merge merge) { | |
| if (first == last) { | |
| return first; | |
| } | |
| FwdIter cur = first; | |
| for (++first; first != last; ++first) { | |
| if (eq(*cur, *first)) { |
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 etude { | |
| namespace functions_ { | |
| template<class T> | |
| constexpr T copy_(T x) noexcept | |
| { | |
| return x; | |
| } | |
| } | |
| using namespace functions_; |
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 <type_traits> | |
| template<class T> | |
| struct type {}; | |
| #define TYPE_OF(...) (type<decltype(__VA_ARGS__)>{}) | |
| struct is_callable_t | |
| { | |
| template<class F, class... Args, |
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 <type_traits> | |
| #include <utility> | |
| // checking whether U{std::declval<T>()} is well-formed, | |
| // where U is typename std::decay<T>::type | |
| template<class T> | |
| struct is_decay_copyable | |
| : std::is_constructible<typename std::decay<T>::type, T>::type {}; | |
| // typename decay_if_possible<T>::type is defined as typename std::decay<T>::type, |
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
| import Data.List (minimum) | |
| import Data.Function (on) | |
| import Data.Ratio ((%)) | |
| -- return minimum element compared by given function | |
| -- (return value used by compare, too) | |
| -- another implementation (more generic ver.) | |
| newtype CompOnSnd a b = CompOnSnd { fromCompOnSnd :: (a, b) } |
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
| {-# LANGUAGE RankNTypes #-} | |
| import System.Random | |
| import Data.Functor | |
| import Control.Monad.Identity | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.List | |
| type Factory m r = Monad m => (forall a. [a] -> m a) -> m r |