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
// demonstrating use of Eigen::Map | |
#include <iostream> | |
#include <vector> | |
#include <Eigen/Dense> | |
int main() { | |
using namespace Eigen; | |
std::vector<float> foo{1.0, 2.0, 3.0, 4.0}; | |
Map<Matrix<float, Dynamic, 1>> foom(foo.data(), foo.size()); | |
IOFormat OctaveFmt(StreamPrecision, 0, ", ", ";\n", "", "", "[", "]"); |
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
// experimenting with zip iterator and sort | |
#include <vector> | |
#include <iostream> | |
#include <boost/iterator/zip_iterator.hpp> | |
#include <boost/fusion/adapted/std_tuple.hpp> | |
using zip_it = boost::zip_iterator<std::tuple<std::vector<std::size_t>::iterator, | |
std::vector<std::size_t>::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
#include <iostream> | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/optional.hpp> | |
#include <boost/optional/optional_io.hpp> | |
int main() { | |
using namespace std; | |
// parsing parentheses that may or may not contain integers | |
string in("(10) () (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 <string> | |
#include <vector> | |
#include <boost/spirit/include/qi.hpp> | |
using string_it_t = std::string::const_iterator; | |
int main() { | |
using namespace boost::spirit; | |
using namespace boost::spirit::qi; |
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
// To see if a rule whose attribute is sequence-of-sequence can make appends happen somehow | |
#include <string> | |
#include <vector> | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/fusion/include/adapt_struct.hpp> | |
struct tiny { | |
std::string thing; |
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 <cstdint> | |
#include <limits> | |
int main(int argc, char **argv) { | |
std::int32_t i = std::numeric_limits<int32_t>::max(); | |
i++; // signed overflow | |
if (i < 0) { | |
std::cerr << "i<0 and i=" << i << "\n"; // "expected" or "safe" result (-O1) | |
} else { |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /> | |
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" /> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> | |
<!-- Optional Mousewheel support: https://github.com/brandonaaron/jquery-mousewheel --> |
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
// a test case for combining semantic actions with synthesized attributes in the same rule | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <iterator> | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/phoenix.hpp> |
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
// An attempt to generically parse expressions like this: | |
// <token> <int> ; | |
// - <some-expr> ; | |
// - <some-expr> ; | |
// - <some-expr> ; <- exactly as many times as given by <int> above | |
// END <token> | |
// where <token> is a string, and <some-expr> is a rule with attribute A | |
// the synthesized attribute of the result should be a fusion sequence of A | |
// Furthermore the resulting grammar should check the number of <some-expr> and ensure it | |
// matches the supplied <int>, with (ideally) a suitable error message |
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
// A test case for gcc 4.7.2 crash | |
// Author: Jeff Trull <jeff.trull@ciere.com> | |
#include <vector> | |
#include <algorithm> | |
template<class Base> | |
class MyClass : Base | |
{ | |
public: |