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
static A& GetInstance() { | |
if (!mInstance) { | |
//クラス内ではコンストラクタが呼べるので有効なコード | |
//クラス外だとNG | |
struct Instantiate :public A { | |
Instantiate() {}; | |
}; | |
mInstance = make_unique<Instantiate>(); |
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<memory> | |
using std::unique_ptr; | |
using std::make_unique; | |
//シングルトン | |
class A { | |
public: | |
static A& GetInstance() { | |
if (!mInstance) { |
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
/* | |
作者 :mstybird | |
Twitter :@mstybird | |
*/ | |
#include<iostream> | |
#include<vector> | |
#include<string> | |
#include<sstream> |
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<vector> | |
#include<ctime> | |
using namespace std; | |
struct Data { | |
float f; | |
double d; | |
int i; | |
}; |
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<vector> | |
using namespace std; | |
int main() { | |
vector<int> data = { | |
0,10,20,30,40,50,60 | |
}; | |
//予め逆順にしておく |
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<vector> | |
using namespace std; | |
int main() { | |
vector<int> data = { | |
0,10,20,30,40,50,60 | |
}; | |
//2番目の要素(20)を削除する |
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<vector> | |
#include<string> | |
#include<algorithm> | |
using namespace std; | |
struct Sample { | |
int id; | |
string str; |
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<vector> | |
#include<algorithm> | |
using namespace std; | |
template<typename T> | |
void OutVector(vector<T>&aData) { | |
for (auto&x : aData) { | |
cout << x << ","; | |
} |
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<stdio.h> |