C++ Logo

SG10

Advanced search

Subject: Re: [SG10] Should there be feature-testing for library features?
From: Niall Douglas (ndouglas_at_[hidden])
Date: 2013-01-25 13:25:38


> Interesting. Despite the fact that the problems you and I are considering
can be
> described in (a very few) similar words, there's actually no technical
> commonality between them.

Hence me asking about the definition of features :)

> You want to add features to the language so programs can adapt to the
> environment in interesting ways.
>
> On the other hand, I want to enable programs to adapt to different
> implementations with different features -- very specifically without
adding any
> new features to the language, so this adaptation can work even with
> implementations that already exist today.

Agreed, except for the part about adding new features to the language. For
example, I would imagine my interpretation would be best served by the
compiler making its internals available as a set of type definitions in an
internal namespace: let's call it __compiler_internals__.

Then metaprogramming could test for file presence like this:

static const char *malloc_h_path1="/usr/include/malloc.h";
static constexpr bool
malloc_h_exists=__compiler_internals__::file_exists<malloc_h_path1>::value;

const char *'s with external linkage are allowed as template parameters of
course. They are pretty useless though (no metaprogrammed string
processing). Metaprogrammed string processing I'm sure another SG will look
into.

In other words, no new language features, merely a mapping of compiler
internals to a special namespace as C++ types.

Niall




SG10 list run by sg10-owner@lists.isocpp.org