0

Instead of using typedef typename for the iterator is it possible to use using keyword?

I tried using schedulable_ops_t::iterator = schedulable_ops_iterator_t; but I get an error is not a base type for type.

brewdogNA
  • 25
  • 5

1 Answers1

0

This record

using schedulable_ops_t::iterator = schedulable_ops_iterator_t;

is incorrect. It seems you mean

using schedulable_ops_iterator_t = typename schedulable_ops_t::iterator;
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
  • The "using" directive let's you define types similar to how you would assign values. I.e. `variable = value` is the idea for `new_type_name = type`. That is one of the reasons "using" is now preferred to typedef. It is easier to work with since the order of thinking is no longer "reversed". – Hajo Kirchhoff Dec 13 '21 at 18:32
  • It also allows templating. There’s no reason to still use `typedef`. – Ben Dec 14 '21 at 03:30
  • `typedef` used the thinking of variable declarations: `typedef type identifier`, so nothing fundamentally wrong with its thinking direction either. There are more important reasons for `using` (see. e.g. https://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11) – Sebastian Jan 18 '22 at 10:46