quote:Original post by Seriema
petewood: I was under the impression that templates only inline under the same conditions as normal inlines, no loops etc? as always, inlines are only a recommendation to the compiler. It''ll probably inline it anyway (since it''s just two rows), but I put it there more for the coder than the compiler.
Unfortunetly, there are two concepts called ''inline''. The C++ keyword has little to do with what you are talking about. When you declare a function inline, you are telling the compiler that this function is being declared in a header, and not to produce duplicates of it when compiling so the linker does not get confused.
//header.h
void test()
{
//...
}
//source1.cpp
include header.h
//source2.cpp
include header.h
When it links, you''ll get an error about two functions both called test.
inline void test() fixes the problem.
__inline, __forceinline et. al. will give the compiler hints to inline the code (and are not part of the standard).