0

Lets say I implement some functions for type Foo. If they are member functions VS will offer them for a foo object but if I implement them as free / non-member functions then I get no help.

foo.doSomething();

//vs

doSomething(foo);

If it is as common as normalize(some_vector) then it is OK but otherwise I have to search for the functions. How do people who use many free functions usually solve this? is there a workaround? Is putting those functions into a descriptive namespace a good idea? FooFunctions::doSomething(foo);

Newline
  • 769
  • 3
  • 12
  • "Is putting those functions into a descriptive namespace a good idea?" Yes, always. Else your global functions might clash with someone else's global functions. – Bathsheba Dec 21 '21 at 09:45
  • non-member functions are typically considered as part of the interface and you can find them in documentation. Take `std::string` for example, it has loads of member functions but also a bunch of non-member functions https://en.cppreference.com/w/cpp/string/basic_string – 463035818_is_not_an_ai Dec 21 '21 at 09:45
  • @463035818_is_not_a_number One of the things about non-member functions, that people who are not the author of the class can write them if they use the interface provided by the class. Kinda extending the class without having to modify the class. Also, what do you mean by "find them in the documentation"? Is the time to find them comparable to what I get when VS offers member functions after I type the `.`? – Newline Dec 21 '21 at 10:07
  • @Bathsheba They wont. People use their own namespace for their projects. – Newline Dec 21 '21 at 10:09
  • Namespace is great. You can also specify the name of the function. – Minxin Yu - MSFT Mar 16 '23 at 07:35

0 Answers0