Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
GCC attributes
killerbot:
From the slides of Scott Meyers workshop :
class Widget
{
public:
int weight() const;
};
std::vector<Widget> vw;
std::sort(vw.begin(), vw.end(), ???);
What's best way for the sorting criterion ?
- a function ?
- function object ?
Function object might be like this :
struct WidgetLess : public std::binary_function<Widget, Widget, bool>
{
bool operator()(const Widget& lhs, const Widget& rhs) const
{return lhs.weight() < rhs.weight();}
}
stuff mentioned about the function object :
* it's a class with an (implicitly) inline operator() function
* compilers routinely inline calls to such functions
So does that first note state that it is guaranteed to be inlined ?? I am not sure (anymore?) ?
I am still convinced that if also in this case it is still a suggestion, it is as strong as specifying inline, or they are just the same.
In the c++ conference last month in Vegas, several speakers have 'said' that implementation in the class body == inline.
Though I'dd like to see this in black on white in printing, will browse through my books some evening.
killerbot:
Scott Meyer's : Effective STL (item 46) : page 202
If a function object's operator() function has been declared inline (either explicitly via 'inline' or implicitly by defining it in its class definition), ....
Navigation
[0] Message Index
[*] Previous page
Go to full version