Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@picanumber
Created January 11, 2017 14:22
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 picanumber/12c209f9248df785d031714141f6893c to your computer and use it in GitHub Desktop.
Save picanumber/12c209f9248df785d031714141f6893c to your computer and use it in GitHub Desktop.
Implementation of a binding element
template <class T>
struct sorted_element
{
std::remove_reference_t<T>* _data;
std::vector<std::size_t> const* _is;
sorted_element(T& elem, std::vector<std::size_t> const& is)
: _data(&elem), _is(&is)
{
}
decltype(auto) operator[](std::size_t i)
{
return _data->at(_is->at(i));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment