Why does boost recommend using core functions over member functions?

The documentation for boost.geometry states

Note: prefer to use x = bg :: get : <0> (point1);
(unlike x = point1.get <0> ();)

I saw this elsewhere in the enhancement docs. Why is my question? Is it a best practice, a performance thing, or some kind of quirk? Is this a general rule or specific to this library?

+4
source share
1 answer

This is not in itself, but a modern C ++ API design.

  • -, Api . ( , , , ).

  • , , . : fusion/tuple.hpp , IO, , , ( ) : fusion/tuple_io.hpp.

  • , friend ( ).

  • " " ADL:

    using std::swap;
    swap(a, b); // will lookup `swap` in the namespaces that declare the parameter types
    

    ( )

  • , , OO ( ). , .

. , , :

  • , -
  • .template ( @Simple)
  • : .

    • ++ 03 std::swap()
    • ++ 11 std::begin() std::end()
    • std::hash<>, std::less<>, std::greater<>, std::equal_to<> , ( , )
+14

All Articles