C++语法

在了解pytorch时发现, C++的代码出了很多新特征,对于简化代码有很大帮助。记录一下

#include <iostream>
#include <vector>
using namespace std;

std::vector<double> create_vector() {
  return {0,1.1,2,3,4};
}

int main(int argc, char* argv[]) {
	auto v = create_vector();
	for (auto p = v.begin(); p!=v.end(); ++p)
            cout << *p << endl;
	return 0;
}
g++ -o3 -std=c++17  -o test  test.cpp  &&  ./test
原文地址:https://www.cnblogs.com/bregman/p/10834433.html