This file contains 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 <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <fstream> | |
#include <regex> | |
#include <string> | |
#include <vector> | |
#include <boost/optional.hpp> | |
using namespace std; |
This file contains 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 <chrono> | |
#include <utility> | |
template <class F, class ...Args> | |
std::chrono::system_clock::duration take_time(F&& f, Args&&... args) { | |
namespace chrono = std::chrono; | |
auto const begin = chrono::system_clock::now(); | |
f(std::forward<Args>(args)...); | |
auto const end = chrono::system_clock::now(); |
This file contains 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> | |
#include <iterator> | |
#include <vector> | |
#include <algorithm> | |
void merge_sort(std::vector<int>& arr) { | |
if (arr.size() <= 1) return; | |
auto left = std::vector<int>(arr.begin(), arr.begin() + arr.size() / 2); | |
auto right = std::vector<int>(arr.begin() + arr.size() / 2, arr.end()); | |
merge_sort(left); |
This file contains 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 <array> | |
#include <algorithm> | |
#include <iostream> | |
#include <tuple> | |
#include <utility> | |
template <typename ...Args, std::size_t N = sizeof...(Args)> | |
std::array<std::common_type_t<Args...>, N> make_array(Args&&... args) | |
{ | |
return {{std::forward<Args>(args)...}}; |
This file contains 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 <iterator> | |
#include <type_traits> | |
template <class Container> | |
auto to_index(const Container& container, typename Container::const_iterator it) | |
-> decltype(std::distance(std::begin(container), it)) | |
{ | |
static_assert(std::is_same< | |
typename std::iterator_traits< | |
typename Container::const_iterator |
This file contains 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
constexpr int f() { return 0; } | |
constexpr int g(); | |
static_assert(noexcept(f()), ""); | |
static_assert(!noexcept(g()), ""); | |
constexpr int h(bool b) { return b ? 0 : throw 42; } | |
static_assert(noexcept(h(true)), ""); | |
static_assert(!noexcept(h(false)), ""); |
This file contains 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 <initializer_list> | |
#include <iostream> | |
#include <string> | |
#include <tuple> | |
#include <type_traits> | |
#include <unordered_map> | |
#include <utility> | |
#include <vector> | |
template <typename F, typename... Args> |
This file contains 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 <vector> | |
#include <numeric> | |
#include <unordered_map> | |
#include <iterator> | |
#include <functional> | |
#include <type_traits> | |
#include <utility> | |
template <typename T, typename A> | |
std::string to_string(std::vector<T, A> const& v); |
This file contains 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
/* | |
入力 | |
4 | |
0 0 1 0 | |
0 1 1 0 | |
0 1 0 1 | |
1 1 1 0 | |
3 | |
0 1 1 | |
0 1 0 |
This file contains 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> | |
class drawable | |
{ | |
struct vtable | |
{ | |
void(*draw)(void*); | |
}; | |
template <typename T> |
OlderNewer