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
std::function<double(double,double)> Func = [](double val1, double val2)->double{return std::max(val1*val1,val2*val2);}; | |
double Ans = Func(10,-12); | |
//Ans==144 |
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 <fstream> | |
#include "csv_iterator.hpp" | |
int main(){ | |
//カンマ区切り(csv)でファイルを読みだして、タブ区切りで画面に出力する | |
auto oitr = csv::current(std::cout, csv::mode::tsv); | |
std::ifstream fin("data.csv"); | |
for(auto itr = csv::begin(fin, csv::mode::csv); itr != csv::end(fin); ++itr){ |
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
std::vector<int> make_rand_array_unique(const size_t size, int rand_min, int rand_max){ | |
if(rand_min > rand_max) std::swap(rand_min, rand_max); | |
const size_t max_min_diff = static_cast<size_t>(rand_max - rand_min + 1); | |
if(max_min_diff < size) throw std::runtime_error("引数が異常です"); | |
std::vector<int> tmp; | |
auto engine = create_rand_engine(); | |
std::uniform_int_distribution<int> distribution(rand_min, rand_max); | |
const size_t make_size = static_cast<size_t>(size*1.2); |
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
//通常のポインタがほしい時には、get関数を使う。 | |
//ポインタの所有権はunique_ptrが保持し続ける | |
int* pint; | |
pint = ptr.get(); | |
//所有権自体を放棄する場合は、release関数を使う | |
//この場合、メモリの解放自体は自分で行う必要がある | |
pint = ptr.release(); | |
delete pint; |