Boost logo

Boost Users :

Subject: Re: [Boost-users] Emulating Python class variables in C++
From: Michael (mwpowellhtx_at_[hidden])
Date: 2015-08-02 21:16:38

On August 2, 2015 8:41:08 PM EDT, Gavin Lambert <gavinl_at_[hidden]> wrote:
>On 2/08/2015 20:05, Will Hall wrote:
>> struct A {
>> static string value;
>> };
>> struct B : public A {
>> static string value;
>> };
>> string A::value("A");
>> string B::value("B");
>While I can't answer your question directly, I can tell you that this
>bad coding practice in C++. Usually it stems from a misunderstanding,
>while other times it's just a bad design.

Have you considered type traits. Don't know how that works with python though.

template<class T>
struct policy {
static const bool value = false;

struct policy<A> {
static const bool value = true;

There's an interesting tutorial here:

>> So, to summarise, any idea how to provide polymorphic Python class
>> variables in boost::python?
>Static/class fields cannot be polymorphic, by definition.
>Boost-users mailing list

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at