As far as I know, if we don't ask template to generate the code for us
It would not do it because template is "lazy". The codes generated by
template are same as handcrafted codes, so what makes template being blamed
by code bloat if you know how to handle it properly? I heard some guys say
template can't be used on embedded system because it would cause code bloat.
It looks like an inevitable side effect bring by template.

Do we really have some situations that we must take the price of code bloat?
Pointer type could be solved by specialize or smart compiler, nontype parameter
could be factor out too.What makes code bloat become an inevitable side effect bring by template?Should I stop using template if I have to develop software on embedded system?

Thank you very much.

The codes generated by template are same as handcrafted codes, so what makes template being blamed by code bloat if you know how to handle it properly?

Nothing, if you handle it properly. Most of the time there's a lack of understanding about how templates work, ignorance of the solutions when bloat occurs, failure to recognize that implementations have improved drastically, or an unfair comparison with type-unsafe methods such as generic pointers. The result is this stigma that templates are always bloated.

Do we really have some situations that we must take the price of code bloat?

If the non-bloaty ad hoc solution turns out to be larger than templates (I've seen this happen), that's a situation where the price of "template code bloat" is better than the alternative. ;)

Should I stop using template if I have to develop software on embedded system?

You should educate yourself on the issue as well as the alternatives, and use your brain when developing software, embedded or not. Simply banning a useful feature because ignorant people think it's problematic is stupid.

You should educate yourself on the issue as well as the alternatives, and use your brain when developing software, embedded or not

Thanks a lot

Do we really have some situations that we must take the price of code bloat?

Do we really have some situations where we couldn't use assembly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.