lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 16/03/2014 11:27 AM, Coda Highland wrote:
On Sat, Mar 15, 2014 at 7:57 PM, David Crayford <> wrote:
On 16/03/2014 4:26 AM, Jeremy Ong wrote:
I've been working on a Lua library recently that uses classes, but other
than that I've avoided C++ features (such as templates and the STL) for
that I don't want my library to depend on a huge C++ runtime. I hope I
haven't got it all wrong... Classes are damn nice to have (and templates
would be nice too), but I don't want to drag in all of the STL and have
library be potentially unusable on small devices.
You realize templates are a compile-time thing right?

And use of templates usually produces much larger object code when compared
to C. Every time you use std::string the compiler will generate lots of
Hence C++11 and extern templates (a very useful new feature).
Object code, yes, but not final linked code; the linker collapses the
duplicate definitions so your final output really isn't substantially
larger. Extern templates make the linker's job easier and help
insulate it from differences in preprocessor state, and should also
improve compile times.

A lot of template functions end up being in-lined, although there are compiler options to control that.

Anything that can improve C++ compile times is manna from heaven! We have a large application that takes about an hour to build and it's mostly templates.
extern templates have eased the pain somewhat.

/s/ Adam