-4

I am unable to understand the below statement and also how to use it? Statement

using A = ::B::C<::D::E, F>

Following are the things, I would like to know:

  1. My understanding is that using is a keyword for aliasing. So instead of ::B::C<::D::E, F>, I can use A. Is this correct?
  2. What is the role of :: before B? As far as I know B is a namespace.
  3. Does :: before B and :: before D imply same thing?
  4. What does angular bracket <> do? Can I assume it as function () with 2 arguments?
  5. How to use A? can I use A like we use functions? Something like A(G, H)?

I have good understanding of basic c++ i.e. loops, arrays, functions, basic classes, basic inheritance etc. In other words, things present in C programming language along with basic OOPs.

Thank you in advance.

  • Be carfull, "aliasing" in C++/C have a special meaning (https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule) – Martin Morterol Jun 09 '23 at 09:35
  • 1
    One question per question please! And note there are several duplicates available for some you ask. – πάντα ῥεῖ Jun 09 '23 at 09:36
  • 2
    Get a good book from [this list](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Jun 09 '23 at 09:54
  • 1
    `::B::C<::D::E, F>` is probably a class template. For type "C" in global namespace "B", with first template argument being a type "E" from global namespace "D", and "F" being a type from an unspecified namespace. And then "A" is an alias for the more complex type on the right. – Pepijn Kramer Jun 09 '23 at 10:00
  • It means you need to work with people who are better at choosing expressive names for things. – Toby Speight Jun 09 '23 at 12:59
  • I hope the reason for that is the OP obfuscated the code to remove the expressive names for security / IP purposes. – drescherjm Jun 09 '23 at 15:07

1 Answers1

3

So instead of ::B::C<::D::E, F>, I can use A. Is this correct?

Yes

What is the role of :: before B? As far as I know B is a namespace.

It's specifies that B should be the first level of namespace. More info here.

Does :: before B and :: before D imply same thing?

Yes

What does angular bracket <> do? Can I assume it as function () with 2 arguments?

It's a template

How to use A? can I use A like we use functions? Something like A(G, H)?

In this context using is a type alias so ::B::C<::D::E, F> must be a type. You will use A the same way you use ::B::C<::D::E, F>.

Martin Morterol
  • 2,560
  • 1
  • 10
  • 15