Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active January 29, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/8fdc9de51488825e23c0010a91887a1f to your computer and use it in GitHub Desktop.
Save deque-blog/8fdc9de51488825e23c0010a91887a1f to your computer and use it in GitHub Desktop.
template <typename T>
int const* get_as_cst(expression_r<T> const& e)
{
return boost::get<int>(&e);
}
template <typename T>
id const* get_as_var(expression_r<T> const& e)
{
return boost::get<id>(&e);
}
template <typename T>
add_op<T> const* get_as_add(expression_r<T> const& e)
{
return boost::get<add_op<T>>(&e);
}
template <typename T>
mul_op<T> const* get_as_mul(expression_r<T> const& e)
{
return boost::get<mul_op<T>>(&e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment