Path: utzoo!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!pilchuck!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c++ Subject: Re: Inline constructor problem Message-ID: <2114@dataio.Data-IO.COM> Date: 30 Aug 89 18:42:53 GMT References: <1990010@hpctdlk.HP.COM> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 19 In article <1990010@hpctdlk.HP.COM> blv@hpctdlk.HP.COM (Bob Vixie) writes: >I have a problem with inline constructors. We are building a large >library of classes that make up our system. If you make your constructors global functions instead of inline, I suspect you'll discover a major decrease in the size of your program with practically no performance penalty. C++ has a problem in that its syntax makes it easier to make a member function inline than not, so many programmers go overboard with inlines. Some general rules for if a function should be inline or not: 1. Constructors should not be inline. The reason is that even though the body of the ctor looks trivial, the compiler may insert a bunch of hidden stuff (such as base class constructor calls) that can cause a surprising amount of bloat. Grouping all the ctors into one module also portably solves the problem of multiple vtbls without kludges like +e0 and +e1. 2. Member functions should be inline if they consist of one expression, otherwise they should be global.