Skip to main content
2 of 5
added 197 characters in body

how objects fit into modern c++ (stl, policy-classes, functional) style?

i'm a bit confused so the question is a bit confusing. TL;dr: how to mix stl and oop.

from the comment to http://programmers.stackexchange.com/questions/147939/best-overview-to-modern-c-paradigms and http://www.boost.org/community/generic_programming.html there isn't much about objects-oriented programming. (boost guidelines mention object generators).

when planing a program, it seems that stl and objects should fit well together. you think of an algorithm and how to do things, then you think of what are the things you want to work with and what properties/characteristics they have. you express those things in terms of tuples and containers and you apply algorithms to them. from my understanding, that's stl style of thinking.

now this is where objects come in. they are things that you do stuff with that contain data, algorithms that change that data and interfaces. but that overlaps with idea of stl where you separate data and algorithms.

in oo you combine data and algorithms and in stl you separate it.

Although mathematically and generically stl make more sense (when you can apply the algorithm to anything), it is easier to think conceptually in oo style when you have a lot of different objects and algorithms -- you get a better organization. for example, qt-style advocates using minimal and orthogonal interfaces specific to a class as oppose to general algorithms. I said specific because their objects are different and they ask for minimal interfaces meaning objects won't share the same interfaces.

so the question is: "can you get away with stl in modern c++ or should you use objects? and if you have to use objects then how?"

other relevant questions: