home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: & of inline functions
- Message-ID: <1992Dec16.181807.25828@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Dec13.185310.20140@math.ufl.edu> <1992Dec15.233031.11712@news.mentorg.com>
- Date: Wed, 16 Dec 1992 18:18:07 GMT
- Lines: 38
-
- dgrammel@dgrammel.mentorg.com (Dave Grammel) writes:
-
- >In article <1992Dec13.185310.20140@math.ufl.edu>, x9999bvj@maple.circa.ufl.edu writes:
- >|>
- >|> What is the official method for handling taking the address of an inline
- >|> function?
-
- >Don't make it inline.
-
- Nonsense. An inline function is just a function. You take its address
- in exactly the same way as you would any function of its type.
- Examples:
-
- inline int ordinary(int i) { return i; }
-
- int (*fp)(int) = ordinary;
-
- class X {
- public:
- int member(int i) { return i; } // inline
- };
-
- int (X::*mfp)(int) = &X::member;
-
- In such cases, the compiler will create a callable version of the
- inline function for you, and use that address. You could then have
- both inline and non-inline uses of the function in the same program.
- Continuing the previous examples:
-
- foo()
- {
- int j = ordinary(3); // expanded inline
- int k = fp(4); // called via the pointer
- ...
- }
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-