I would like to make the member function "find" of set
could find different member data of the record
How could I do that except of std::find_if?Thanks
Implement the STL iterator interface? PS: function definitions in classes are bad - that may easily lead to (it doesn't have to, but it does happen a lot) to bloated executable sizes. Aside from that it also reduces the readability of your class (the reader only needs your interface, he doesn't need to know how you implement it).
Thanks, I know you are right
I define the function in class because I want to save some space on this forum
I would not inline those big function in my class usually and always separate
them in .h and .cpp if I could
Oh wait, you said except find_if? Lol, misread again. Happens a lot to me lately. I also just realized that your record is not a collection (I thought you were talking about a set, so I didn't actually read your code). I think I didn't quite understand what you want, could you please tell me again?
Nevermind, I think it is impossible for a single set or map to search different "key"(set don't have key) effectively
I want to implement a simple search engine
class "record" store the contents I want to search for
But the users may change their search target(like price, author, title and other's)
Maybe I should mix with other data structures
Or safe different key in different map or unordered_map?
But this would cost me a lot of memory
Besides, unordered_map can't list the data by order
If the linker doesn't optimize properly you will be left over with huge executables. Of course a good linker won't have such problems, but you don't always have one. That's why I said "can" and not "will".
I guess my beef was that it was a too-general blanket statement.
You're basically saying "inlining functions is bad because it can make your exe bigger". While technically true on some level, it's extremely misleading.
I didn't mean it to be misleading. The point is, you normally don't want to have your function definitions inside your class, except inline stuff. You'd normally put it in a seperate .cpp file, or for templates at least under the class so the class is a readible interface (yes I know, headers don't replace proper documentation).