A
A
abs_lord2017-10-14 22:15:17
JavaScript
abs_lord, 2017-10-14 22:15:17

How to swap elements in mpl::vector so that derived classes are before their base ones?

I have a sequence of types. Check that they are all classes and arrange them so that the derived classes come before their base ones. For the resulting sequence, check that all classes are derived from the last one.
It is necessary to implement the solution using Boost::MPL
, let's say we have a list of types:

class base1 {};

class child1 : base1 {};

class child2 : child1 {};

class child3 : child2 {};

typedef vector<child2, child1, base1, child3> vec;

It is necessary that after applying the metafunction it turns out: child3, child2, child1, base1
As I understand it, you just need to sort the vector, changing the corresponding types in places, if the first is the ancestor of the second (is_base_of). Tell me how to implement this using Boost MPL?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DanKud, 2019-07-12
@neverever

If child 2 is after child 1 then: If child 2 is above child 1 then:
.parent().find('селектор')

D
Dima, 2019-07-12
Dolgoter @SpiderPigAndCat

.next()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question