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
//Generico. Sem tipos declarados | |
#define FILL(v, i, start, end, step) { \ | |
for(i=start; i < end; i+=step) \ | |
v.push_back(i); \ | |
} | |
#define ACCUM(v, ret) { \ | |
for(size_t i=0; i < v.size(); i++) \ | |
ret += v[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
template<typename T, typename U> | |
void fill(T &t, U start, U end, U step) { | |
for(U i=start; i < end; i += step) { | |
t.push_back(i); | |
} | |
} | |
template<typename T> | |
auto accum(T &t) { | |
typename T::value_type ret{}; |
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
template<typename T, typename U> | |
void fill2(T &v, U start, U step) { | |
*begin(v) = start; | |
generate(begin(v)+1, end(v), [&start, &step]() { return start += step; }); | |
//alternative - this is not a proper std::fill, but a generate | |
//for(auto &item : v) { | |
// item = start; | |
// start += step; | |
//} |
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
void log_print(const std::string &str) { /* ... */ } | |
bool isInfoEnabled() { /* ... */ } | |
#define LOG_INFO(fmt, x) { \ | |
if(isInfoEnabled()) log_print(boost::str( boost::format(fmt) % 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 <vector> | |
#include <cstdio> | |
using namespace std; | |
//this function will be generated | |
int c_accum_i(vector<int> &v) | |
{ | |
int ret{}; | |
for(const auto &i : 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
std::cout << "Hello from Fabio !" << std::endl; | |
std::cout << "Hello from Thiago !" << std::endl; | |
std::cout << "Fabio hopes you like the site !" << std::endl; | |
std::cout << "Thiago hopes you like the site !" << std::endl; |
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
struct Field { | |
unsigned int f1; //int=4 bytes | |
unsigned char f2; //char=1 byte | |
}; |
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
struct FieldC { | |
unsigned char f1; //char=1 byte | |
unsigned int f2; //int=4 bytes | |
}; |
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
struct Field4 { | |
unsigned char f1; //char=1 byte | |
unsigned int f2; //int=4 bytes | |
unsigned char f3; //char=1 byte | |
}; |
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
struct Field5 { | |
unsigned int f2; //int=4 bytes | |
unsigned char f1; //char=1 byte | |
unsigned char f3; //char=1 byte | |
}; |