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
#include <string> | |
#include <iostream> | |
#include <sstream> | |
#define BOOST_SPIRIT_USE_PHOENIX_V3 | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/phoenix.hpp> | |
int main() { |
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 <boost/spirit/include/lex_lexertl.hpp> | |
#include <boost/spirit/include/lex_lexertl_position_token.hpp> | |
#include <boost/spirit/include/support_istream_iterator.hpp> | |
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/phoenix.hpp> | |
#include <boost/algorithm/string/case_conv.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
// test transforming a mutating function into a value-returning function via Phoenix | |
// i.e., void f(T& a) -> T f(T const& a) or T F(T a) | |
#define BOOST_SPIRIT_USE_PHOENIX_V3 | |
#include <iostream> | |
#include <string> | |
#include <boost/spirit/include/phoenix.hpp> | |
#include <boost/algorithm/string/case_conv.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
#include <iostream> | |
#include <vector> | |
#include <Eigen/Dense> | |
#include <Eigen/Sparse> | |
int main() { | |
using namespace std; | |
using namespace Eigen; | |
vector<Triplet<double> > tripletList; |
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 <typeinfo> | |
#include <string> | |
#include <iostream> | |
template<typename T> struct A { | |
template<typename U> | |
A(U u) { | |
std::cout << std::string("class template parameter generic, ctor template parameter ") + typeid(u).name() << 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
#include <typeinfo> | |
#include <string> | |
#include <iostream> | |
template<typename T> struct A { | |
template<typename U> | |
void foo(U u) { | |
std::cout << std::string("class template parameter generic, function template parameter ") + typeid(u).name() << std::endl; | |
} | |
}; |