This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: numeric_limits<array type> generates a compiler error


2013/2/6 Andy Venikov <avenikov@google.com>:
> I thought that numeric_limits were supposed to work for any type, not
> just arithmetic types.

I think it does depend on what you mean with "supposed to work".

> The following program, when compiled with gcc 4.7.2, gives a compiler error.
>
> #include <limits>
>
> int main(int, char**)
> {
>    bool b = std::numeric_limits<char[10]>::is_integer;
> }
>
> /limits:309:7: error: function returning an array
>
> The function in question is min()
>
> Is this a problem? Or is it expected?

Good question, but I would expect that your code would instantiate the
primary template of numeric_limits. Doing so and attempting to access
is_integer seems like a valid request to me as indicated layout of the
primary template synopsis. There is also evidence for this by explicit
wording in p1:

"The default numeric_limits<T> template shall have all members, but
with 0 or false values."

I would expect that your code should work.

- Daniel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]