Boost logo

Boost :

Subject: Re: [boost] [static_if] Is there interest in a `static if` emulation library?
From: pfultz2 (pfultz2_at_[hidden])
Date: 2014-09-01 23:41:49

> Clever! However, IMO the `auto f` would look somewhat arbitrary to users.

I agree, it needs a better name. Jamboree has suggested `lazy`, which sounds
good. Of course the name is defined by the user(unless a macro was used over
top of this), they could pick anything, even a `_` could be used(not that I
think it is a great idea).

> I know... too bad enable_if cannot be used to disable these data
> member declarations.

You can use enable_if for member functions, by using a default template
parameter. So you can disable `f` in your example, like this:

    template< bool B >
    struct x {
        typedef typename boost::mpl::if_c<B, int, unusable>::type
        value_type v; // unfortunately, this can't actually be disable, so
make it useless.

            bool InternalBool = true,
            class=typename std::enable_if<InternalBool && B>::type>
        void f ( ) {
            value_type w;
            w = v;

The `InternalBool` is used to make the boolean clause in the enable_if
dependent, otherwise it wouldn't work.

However, I don't know a way to disable member variables and types using
enable_if. Perhaps there is a way, I'm not aware of yet.


View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at