9

I am coming from c to c++ and familiar with the syntax. But I just came across the code with syntax im not familiar with

int main() {
    std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
    std::shared_ptr<HelloWorldProxy<>> myProxy =
        runtime->buildProxy<HelloWorldProxy>("local", "test");

Can Someone explain what does syntax something < something > something do also what does syntax something<something<>> something do.

gfdsal
  • 651
  • 1
  • 8
  • 25
  • 3
    http://en.cppreference.com/w/cpp/language/templates – Christian Hackl Mar 22 '17 at 20:34
  • 1
    in `foo`, `foo` is a template and `T` is the template parameter. In `foo<>` there is probably a default for the template parameter – 463035818_is_not_an_ai Mar 22 '17 at 20:36
  • 2
    C and C++ are different languages - they share a lot of syntax but there's plenty of differences. You should not assume it's an easy transition – UnholySheep Mar 22 '17 at 20:36
  • Well I tried googling angle brackets but couldnt find much help before posting here on stacksoverflow. Now it makes so much sense . Thanks! – gfdsal Mar 22 '17 at 20:49
  • 1
    @ShreyasMurali: It is merely showing disapproval of a trial & error learning approach which tries to skip reading books and tutorials. – Christian Hackl Mar 22 '17 at 20:56
  • 1
    +1 because templates are deeper into the language, c++ is vast, and sometimes you just need a hint at what you are encountering to move up the learning curve. (although the "I am familiar with the syntax" is clearly a misstatement and OP should feel bad.) – rebusB Jan 13 '19 at 16:17

1 Answers1

13

You're looking at C++ templates.

...allows a function or class to work on many different data types without being rewritten for each one.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
Alex Taylor
  • 8,343
  • 4
  • 25
  • 40