
Scott Meyers wrote:
Fundamentally, I'm sorting things based on their index in AllTypes. Well, that's what I want to be doing. What I'm really doing is getting compilation errors referring to a missing tag in my metafunction, which is called IndexOf. The code I'm using is below. I'd appreciate it if people would take a look and help me figure out why it's not working.
<snip>
// return the index of type T in sequence S template
struct IndexOf { enum { value = mpl::distance ::type >::value }; }; int main() { using mpl::_1; using mpl::_2;
typedef mpl::vector
AllTypes; typedef mpl::vector
Unsorted; typedef mpl::sort
, // sort doesn't IndexOf > // compile >::type Sorted; }
Try this:
template