3
votes
1answer
292 views

Use a template to get alternate behaviour?

Is this a bad practice? const int sId(int const id); // true/false it doesn't matter template<bool i> const int sId(int const id) { return this->id = id; } const int MCard::sId(int ...
0
votes
1answer
68 views

How to make C++ template stack work with basic data types and compound variables?

Templates are nice for similar algorithms of different data types. Say I make a template stack of a basic data type... Stack<int> stck(10); stck.Push(5); I'd pop it... int x = stck.Pop(); ...
6
votes
1answer
471 views

“C++ Templates: The Complete Guide” (c) 2002 — up to date with C++11?

The book C++ Templates: The Complete Guide, (c) 2002, looks very appealing to me, but as it's 12 years old, I'm concerned it may be out of date. There are some highly favorable Amazon reviews dated ...
-1
votes
2answers
843 views

Why is C++ preferred over C for commercial applications? [closed]

I program in C mostly. However, it is pretty obvious that many more commercial applications are done in C++. As far as I can tell, C++ is a very complex language, with seemingly convoluted syntax and ...
7
votes
2answers
479 views

How do I avoid writing lots of pass-through functions in a wrapper?

I have a class, which wraps another class of a common base type. Because the base type interface is quite large this involves writing a lot of pass-through functions. I am looking for a way to avoid ...
6
votes
3answers
2k views

How do you handle increasingly long compile times when working with templates?

I use Visual Studio 2012 and he have cases where we added templates parameters to a class "just" in order to introduce a "seam point" so that in unit-test we can replace those parts with mock objects. ...
5
votes
1answer
96 views

How can I port msvc++ code with non-dependent names in templates to Linux?

I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does: template ...
8
votes
8answers
1k views

Is STL implemented with OO?

There are several design patterns like Adaptor, Iterator implemented in STL. Does that mean STL is implemented with OO concepts? What is the relationship between OO and template parts of C++? I ...
5
votes
5answers
633 views

Would “Efficient C++” book be irrelevant now due to compiler improvements?

I am planning on purchasing this book to learn more about C++ programming with regards to fast code. However, the book was published in 1999 and I am worried most of it may be irrelevant now due to ...
1
vote
1answer
270 views

How should the cppcms template hierarchy be used

I understand that the hierarchy, in cppcms for templates, goes skin (topmost, representing a namespace), then view (representing a class) and finally template (representing a function). I want to ...
14
votes
8answers
1k views

How to spread awareness for generic programming among team members?

I am staying in an environment, where people believe: Java generics are the feature exclusively used for library writing and not for the real coding. C++ is an OO programming language; template is ...
7
votes
2answers
969 views

In C++, were SFINAE and metaprogramming intentional or just a byproduct of templates?

SFINAE and template metaprogramming can do wonderful things and many libraries also use them considerably. Historically both of these "magic concepts" were intentionally introduced/supported in C++ ? ...
8
votes
9answers
394 views

Are there any resources on how to identify problems that could best be solved with templates?

I decided to improve my knowledge in template meta-programming. I know the syntax and rules and been playing with counteless examples from online resources. I understand how powerful templates can be ...
3
votes
5answers
2k views

Template Functions and Function templates in C++

I came across a question which asked the difference between Function Templates and Template Functions in C++ and also Template Classes and Class Templates. I was under the impression that Function ...
18
votes
5answers
1k views

Why C++ cannot adopt D's approach for its concept implementation?

As many of you guys know, concepts, C++'s approach for constraining possible types for a template argument has failed to be included in C++11. I learned that the D programming language 2.0 has a ...
14
votes
4answers
3k views

Why are C++ template error messages so horrific?

C++ templates are notorious for generating long, unreadable error messages. I have a general idea of why template error messages in C++ are so bad. Essentially, the problem is that the error isn't ...
16
votes
5answers
3k views

Are C++ templates just a kind of glorified macros?

From different comparisons among C++ templates and C#/Java generics like this one- ...