Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Space tells matter how to move and matter tells space how to curve. -- Wheeler


devel / comp.lang.c++ / Re: Visual C++ 2019 is having a hissy fit over these two lines of code

SubjectAuthor
* Visual C++ 2019 is having a hissy fit over these two lines of codeLynn McGuire
+* Re: Visual C++ 2019 is having a hissy fit over these two lines ofLynn McGuire
|+* Re: Visual C++ 2019 is having a hissy fit over these two lines ofAndrey Tarasevich
||`* Re: Visual C++ 2019 is having a hissy fit over these two lines ofLynn McGuire
|| +- Re: Visual C++ 2019 is having a hissy fit over these two lines of codeKeith Thompson
|| `* Re: Visual C++ 2019 is having a hissy fit over these two lines ofBonita Montero
||  `* Re: Visual C++ 2019 is having a hissy fit over these two lines ofChris M. Thomasson
||   `* Re: Visual C++ 2019 is having a hissy fit over these two lines ofBonita Montero
||    `- Re: Visual C++ 2019 is having a hissy fit over these two lines ofChris M. Thomasson
|+* Re: Visual C++ 2019 is having a hissy fit over these two lines ofAlf P. Steinbach
||`- Re: Visual C++ 2019 is having a hissy fit over these two lines ofPavel
|+* Re: Visual C++ 2019 is having a hissy fit over these two lines ofPaavo Helde
||`* Re: Visual C++ 2019 is having a hissy fit over these two lines ofLynn McGuire
|| `- Re: Visual C++ 2019 is having a hissy fit over these two lines ofPaavo Helde
|`- Re: Visual C++ 2019 is having a hissy fit over these two lines of codeRalf Fassel
`* Re: Visual C++ 2019 is having a hissy fit over these two lines of codeMalcolm McLean
 `* Re: Visual C++ 2019 is having a hissy fit over these two lines ofLynn McGuire
  `- Re: Visual C++ 2019 is having a hissy fit over these two lines ofPaavo Helde

1
Visual C++ 2019 is having a hissy fit over these two lines of code

<u9a76v$2hd12$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=932&group=comp.lang.c%2B%2B#932

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++
Subject: Visual C++ 2019 is having a hissy fit over these two lines of code
Date: Wed, 19 Jul 2023 21:46:54 -0500
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <u9a76v$2hd12$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 02:46:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="265d7ad0a7737ac1b0251caa14c38516";
logging-data="2667554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181FPXqQMFJojwF+iC5t0PmBy/5jA/zqMw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:BrQpLxHjOZjzrYY21E7hl/F82eA=
Content-Language: en-US
 by: Lynn McGuire - Thu, 20 Jul 2023 02:46 UTC

And Visual C++ 2019 is having a hissy fit over these two lines of code:

static const size_t size_t_max = std::numeric_limits<size_t>::max();
static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();

That code worked just fine in Visual C++ 2015. What am I screwing up here ?

Thanks,
Lynn

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9a7al$2hd12$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=933&group=comp.lang.c%2B%2B#933

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Wed, 19 Jul 2023 21:48:52 -0500
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <u9a7al$2hd12$2@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 02:48:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="265d7ad0a7737ac1b0251caa14c38516";
logging-data="2667554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uGaXlde1P1tdRSzkzvq4ccfidV4VcfWo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:S9bXMt/FkCRJVPgnCBUd3jBnXs8=
Content-Language: en-US
In-Reply-To: <u9a76v$2hd12$1@dont-email.me>
 by: Lynn McGuire - Thu, 20 Jul 2023 02:48 UTC

On 7/19/2023 9:46 PM, Lynn McGuire wrote:
> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>
> static const size_t size_t_max = std::numeric_limits<size_t>::max();
> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>
> That code worked just fine in Visual C++ 2015.  What am I screwing up
> here ?
>
> Thanks,
> Lynn

You know, I should give the error code:

Severity Code Description Project File Line Suppression State
Error C2440 'initializing': cannot convert from 'unsigned int (__cdecl
*)(void) noexcept' to 'fem::size_t' dii_c_library
C:\dii\inc\fem\size_t.hpp 12

And here is the file:

#ifndef FEM_SIZE_T_HPP
#define FEM_SIZE_T_HPP

#include <limits>
#include <cstddef>

namespace fem {

typedef std::size_t size_t;
typedef std::ptrdiff_t ssize_t;

static const size_t size_t_max = std::numeric_limits<size_t>::max();
static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();

template <typename T>
struct array_of_2
{
T elems[2];

array_of_2() {}

array_of_2(T const& i, T const& j) { elems[0] = i; elems[1] = j; }
};

typedef array_of_2<size_t> size_t_2;
typedef array_of_2<ssize_t> ssize_t_2;

} // namespace fem

#endif // GUARD

Thanks,
Lynn

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9ae7q$2ibn8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=934&group=comp.lang.c%2B%2B#934

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreytarasevich@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Wed, 19 Jul 2023 21:46:49 -0700
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <u9ae7q$2ibn8$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 04:46:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8f37c01b24d1e8d59ba2f7e9db45af77";
logging-data="2698984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lD8dfJCW+rTwXe6ZTKTE7"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:yKW42OGudjdI1fnWJj7/0LxVgMI=
Content-Language: en-US
In-Reply-To: <u9a7al$2hd12$2@dont-email.me>
 by: Andrey Tarasevich - Thu, 20 Jul 2023 04:46 UTC

On 07/19/23 7:48 PM, Lynn McGuire wrote:
> You know, I should give the error code:

Compiles perfectly fine in my VS2019.

The first thought was that it was just another example of the well-known
conflict with Windows' own min/max macros. But regardless of `NOMINMAX`
state, this code compiled without any issues for me.

--
Best regards,
Andrey

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9agrn$2ir45$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=935&group=comp.lang.c%2B%2B#935

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 00:31:33 -0500
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <u9agrn$2ir45$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 05:31:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1f46bbbf1feea5906d4a8716da8d54fa";
logging-data="2714757"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18B73z/VUITpftVNPzu7NLzLeRJPeqvF6s="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:GIDk+F02MJEbEYWbyL0eD0Ktyfs=
In-Reply-To: <u9ae7q$2ibn8$1@dont-email.me>
Content-Language: en-US
 by: Lynn McGuire - Thu, 20 Jul 2023 05:31 UTC

On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>> You know, I should give the error code:
>
> Compiles perfectly fine in my VS2019.
>
> The first thought was that it was just another example of the well-known
> conflict with Windows' own min/max macros. But regardless of `NOMINMAX`
> state, this code compiled without any issues for me.

Thanks !

I can fix the problem by replacing the
std::numeric_limits<size_t>::max(); with UINT_MAX. But, that is a cheat.

Thanks,
Lynn

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<877cqvruyx.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=936&group=comp.lang.c%2B%2B#936

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of code
Date: Wed, 19 Jul 2023 22:51:50 -0700
Organization: None to speak of
Lines: 22
Message-ID: <877cqvruyx.fsf@nosuchdomain.example.com>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me> <u9agrn$2ir45$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7cb07f2c0431ee5f8bb40869fb2e49a1";
logging-data="2720522"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VvOUnY4MDvZsN86WaXpdf"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:tBU3GNbkvrJSdTDyoeSupABnJWs=
sha1:SnwR06vky68Eqonq1dZdPp6ABnw=
 by: Keith Thompson - Thu, 20 Jul 2023 05:51 UTC

Lynn McGuire <lynnmcguire5@gmail.com> writes:
> On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
>> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>>> You know, I should give the error code:
>> Compiles perfectly fine in my VS2019.
>> The first thought was that it was just another example of the
>> well-known conflict with Windows' own min/max macros. But regardless
>> of `NOMINMAX` state, this code compiled without any issues for me.
>
> Thanks !
>
> I can fix the problem by replacing the
> std::numeric_limits<size_t>::max(); with UINT_MAX. But, that is a
> cheat.

Surely you mean SIZE_MAX, defined in <cstdint>. (It's common for int to
be 32 bits and size_t 64 bits.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9ama3$2jo7l$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=937&group=comp.lang.c%2B%2B#937

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.steinbach@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 09:04:32 +0200
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <u9ama3$2jo7l$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 07:04:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a10c3bfc1693b83fd8b02cfbc0f80740";
logging-data="2744565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180spOi/nJ04Q+vCREsPklM"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:kDTBwZ47jrsA4T1wZ36QJE7EYO8=
Content-Language: en-US
In-Reply-To: <u9a7al$2hd12$2@dont-email.me>
 by: Alf P. Steinbach - Thu, 20 Jul 2023 07:04 UTC

On 2023-07-20 4:48 AM, Lynn McGuire wrote:
> On 7/19/2023 9:46 PM, Lynn McGuire wrote:
>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>
>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>
>> That code worked just fine in Visual C++ 2015.  What am I screwing up
>> here ?
>>
>> Thanks,
>> Lynn
>
> You know, I should give the error code:
>
> Severity    Code    Description    Project    File    Line
> Suppression State
> Error    C2440    'initializing': cannot convert from 'unsigned int
> (__cdecl *)(void) noexcept' to 'fem::size_t'    dii_c_library
> C:\dii\inc\fem\size_t.hpp    12
>
> And here is the file:
>
> #ifndef FEM_SIZE_T_HPP
> #define FEM_SIZE_T_HPP
>
> #include <limits>
> #include <cstddef>
>
> namespace fem {
>
>   typedef std::size_t size_t;
>   typedef std::ptrdiff_t ssize_t;
>
>   static const size_t size_t_max = std::numeric_limits<size_t>::max();
>   static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>
>   template <typename T>
>   struct array_of_2
>   {
>     T elems[2];
>
>     array_of_2() {}
>
>     array_of_2(T const& i, T const& j) { elems[0] = i; elems[1] = j; }
>   };
>
>   typedef array_of_2<size_t> size_t_2;
>   typedef array_of_2<ssize_t> ssize_t_2;
>
> } // namespace fem
>
> #endif // GUARD

I can't see anything technically wrong and it compiles fine with current
Visual C++ and g++.

Not what you're asking but note that

* `typedef` is old C syntax, modern `using` can be more clear.
* `const` at namespace scope implies `static`, i.e. no need to repeat.
* `array_of_2` won't work for T that's not default constructible.

Here's re-styling of the code with the above 3 points addressed:

#pragma once
#include <limits> // std::numeric_limits
#include <utility> // std::move
#include <cstddef> // std::(size_t, ptrdiff_t)

namespace fem {
using std::numeric_limits,
std::move;

using size_t = std::size_t;
using ssize_t = std::ptrdiff_t;

template< class Type >
constexpr Type max_ = numeric_limits<Type>::max();

constexpr size_t size_t_max = max_<size_t>;
constexpr ssize_t ssize_t_max = max_<ssize_t>;

template< class T >
struct array_of_2_
{
T elems[2];

array_of_2_() {}
array_of_2_( T a, T b ): elems{ move( a ), move( b ) } {}
};

using size_t_2 = array_of_2_<size_t> ;
using ssize_t_2 = array_of_2_<ssize_t> ;
} // namespace fem

- Alf

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9aqs1$2khmm$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=938&group=comp.lang.c%2B%2B#938

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesnimi@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 11:22:24 +0300
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <u9aqs1$2khmm$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 08:22:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3688b703d5f9b403e9baa9682a9e90a6";
logging-data="2770646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196byiApeiCr2HzdvoCXp/MWhniodIYu7Y="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:21Z4h7bsqs2CkGeUg0YPL1cID0Y=
In-Reply-To: <u9a7al$2hd12$2@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 20 Jul 2023 08:22 UTC

20.07.2023 05:48 Lynn McGuire kirjutas:
> On 7/19/2023 9:46 PM, Lynn McGuire wrote:
>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>
>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>
>> That code worked just fine in Visual C++ 2015.  What am I screwing up
>> here ?
>>
>> Thanks,
>> Lynn
>
> You know, I should give the error code:
>
> Severity    Code    Description    Project    File    Line
> Suppression State
> Error    C2440    'initializing': cannot convert from 'unsigned int
> (__cdecl *)(void) noexcept' to 'fem::size_t'    dii_c_library
> C:\dii\inc\fem\size_t.hpp    12

This complains about converting a function to an integer. The following
line would emit the same error:

static const size_t size_t_max = std::numeric_limits<size_t>::max;

Suspecting either you did not post the actual failing code, or there is
some evil macro hackery going on. To figure that out, hover the mouse
over 'max', or right-click on it and select 'go to definition'.

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<479fe58d-2e17-4fa8-b6fd-8b5e677c990dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=940&group=comp.lang.c%2B%2B#940

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:2456:b0:768:4206:c616 with SMTP id h22-20020a05620a245600b007684206c616mr8355qkn.4.1689843189817;
Thu, 20 Jul 2023 01:53:09 -0700 (PDT)
X-Received: by 2002:a05:6808:e83:b0:3a4:8115:5e7 with SMTP id
k3-20020a0568080e8300b003a4811505e7mr1841258oil.10.1689843189470; Thu, 20 Jul
2023 01:53:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Thu, 20 Jul 2023 01:53:09 -0700 (PDT)
In-Reply-To: <u9a76v$2hd12$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:e4c9:1be9:910a:4246;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:e4c9:1be9:910a:4246
References: <u9a76v$2hd12$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <479fe58d-2e17-4fa8-b6fd-8b5e677c990dn@googlegroups.com>
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of code
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Injection-Date: Thu, 20 Jul 2023 08:53:09 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1654
 by: Malcolm McLean - Thu, 20 Jul 2023 08:53 UTC

On Thursday, 20 July 2023 at 03:47:12 UTC+1, Lynn McGuire wrote:
> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>
> static const size_t size_t_max = std::numeric_limits<size_t>::max();
> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>
> That code worked just fine in Visual C++ 2015. What am I screwing up here ?
>
> Thanks,
> Lynn
>
Try
static const size_t size_t_max = (std::numeric_limits<size_t>::max)();

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<ygabkg6hg8w.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=941&group=comp.lang.c%2B%2B#941

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of code
Date: Thu, 20 Jul 2023 15:19:59 +0200
Lines: 33
Message-ID: <ygabkg6hg8w.fsf@akutech.de>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 6Q2H7Om6xym8xouIIq88LglpzwA9NQDg1ya9TUVcZZIHAc0fI=
Cancel-Lock: sha1:ypVozSxe7RrshqTD8Lc0LPqESag= sha1:tH09jlyTv7aBKTMoFtnQM9ZznpU= sha256:NSopaV1AgJjYiUI3t+lPzXvm1N4XrRUohzXCc2nTEuY=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 20 Jul 2023 13:19 UTC

* Lynn McGuire <lynnmcguire5@gmail.com>
| Severity Code Description Project File Line Suppression State
| Error C2440 'initializing': cannot convert from 'unsigned int (__cdecl
| *)(void) noexcept' to 'fem::size_t' dii_c_library
| C:\dii\inc\fem\size_t.hpp 12
>
| And here is the file:
>
| #ifndef FEM_SIZE_T_HPP
| #define FEM_SIZE_T_HPP
>
| #include <limits>
| #include <cstddef>
>
| namespace fem {
>
| typedef std::size_t size_t;
| typedef std::ptrdiff_t ssize_t;
>
| static const size_t size_t_max = std::numeric_limits<size_t>::max();
| static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();

Check whether

#undef max
static const size_t size_t_max = std::numeric_limits<size_t>::max();

makes a difference at that position. If so, it *is* the 'max' macro,
and it very much depends on other include files before the current one
whether this triggers or not.

HTH
R'

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9bf9l$2o5nj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=942&group=comp.lang.c%2B%2B#942

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 16:11:02 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <u9bf9l$2o5nj$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me> <u9agrn$2ir45$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 14:11:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10031f0e81423a2c0e359bd216cbd3a1";
logging-data="2889459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gflEbvF8c6+dueqy2QoVL+jIx8WzXBJk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:EX7Cg0yn1NSl4/dmB4hMcBNwP6Y=
Content-Language: de-DE
In-Reply-To: <u9agrn$2ir45$1@dont-email.me>
 by: Bonita Montero - Thu, 20 Jul 2023 14:11 UTC

Am 20.07.2023 um 07:31 schrieb Lynn McGuire:
> On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
>> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>>> You know, I should give the error code:
>>
>> Compiles perfectly fine in my VS2019.
>>
>> The first thought was that it was just another example of the
>> well-known conflict with Windows' own min/max macros. But regardless
>> of `NOMINMAX` state, this code compiled without any issues for me.
>
> Thanks !
>
> I can fix the problem by replacing the
> std::numeric_limits<size_t>::max(); with UINT_MAX.  But, that is a cheat.

For me is #define-ing NOMIMMAX before including <Windows.h>
the smarter solution.

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9c0hh$2r6pq$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=946&group=comp.lang.c%2B%2B#946

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 14:05:19 -0500
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u9c0hh$2r6pq$4@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9aqs1$2khmm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 19:05:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="265d7ad0a7737ac1b0251caa14c38516";
logging-data="2988858"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189tTso1/87YKkMtroQu5JjiLJFK9mdo2k="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:bF55xKbxU50wxSxLD4UmxUjw/04=
In-Reply-To: <u9aqs1$2khmm$1@dont-email.me>
Content-Language: en-US
 by: Lynn McGuire - Thu, 20 Jul 2023 19:05 UTC

On 7/20/2023 3:22 AM, Paavo Helde wrote:
> 20.07.2023 05:48 Lynn McGuire kirjutas:
>> On 7/19/2023 9:46 PM, Lynn McGuire wrote:
>>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>>
>>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>>
>>> That code worked just fine in Visual C++ 2015.  What am I screwing up
>>> here ?
>>>
>>> Thanks,
>>> Lynn
>>
>> You know, I should give the error code:
>>
>> Severity    Code    Description    Project    File    Line Suppression
>> State
>> Error    C2440    'initializing': cannot convert from 'unsigned int
>> (__cdecl *)(void) noexcept' to 'fem::size_t'    dii_c_library
>> C:\dii\inc\fem\size_t.hpp    12
>
>
> This complains about converting a function to an integer. The following
> line would emit the same error:
>
> static const size_t size_t_max = std::numeric_limits<size_t>::max;
>
> Suspecting either you did not post the actual failing code, or there is
> some evil macro hackery going on. To figure that out, hover the mouse
> over 'max', or right-click on it and select 'go to definition'.

I get the following "limits" code for min and max.

template <>
class numeric_limits<unsigned int> : public _Num_int_base {
public:
_NODISCARD static constexpr unsigned int(min)() noexcept {
return 0;
}

_NODISCARD static constexpr unsigned int(max)() noexcept {
return UINT_MAX;
}

Thanks,
Lynn

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9c1d0$2reho$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=947&group=comp.lang.c%2B%2B#947

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 14:19:59 -0500
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <u9c1d0$2reho$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me>
<479fe58d-2e17-4fa8-b6fd-8b5e677c990dn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 19:20:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="265d7ad0a7737ac1b0251caa14c38516";
logging-data="2996792"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tqqzXc3t+gcec0O1eRLgYfpZPCSv4nG8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:q9qShce084dt0/E/8AfjU7oO/9E=
Content-Language: en-US
In-Reply-To: <479fe58d-2e17-4fa8-b6fd-8b5e677c990dn@googlegroups.com>
 by: Lynn McGuire - Thu, 20 Jul 2023 19:19 UTC

On 7/20/2023 3:53 AM, Malcolm McLean wrote:
> On Thursday, 20 July 2023 at 03:47:12 UTC+1, Lynn McGuire wrote:
>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>
>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>
>> That code worked just fine in Visual C++ 2015. What am I screwing up here ?
>>
>> Thanks,
>> Lynn
>>
> Try
> static const size_t size_t_max = (std::numeric_limits<size_t>::max)();

Nope, that threw me into std::max hell. Then I get an error on:

size_t n = std::max(lhs_size, rhs_size);

Thanks,
Lynn

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9c3k8$2rpbs$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=948&group=comp.lang.c%2B%2B#948

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 12:57:59 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u9c3k8$2rpbs$3@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me> <u9agrn$2ir45$1@dont-email.me>
<u9bf9l$2o5nj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 19:58:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1821hA8Ldz8MfL/3LSiZe9m9A3XRkZXBdo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:nNMRsRKR5huLztS9kxpUPdkXcsE=
In-Reply-To: <u9bf9l$2o5nj$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 20 Jul 2023 19:57 UTC

On 7/20/2023 7:11 AM, Bonita Montero wrote:
> Am 20.07.2023 um 07:31 schrieb Lynn McGuire:
>> On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
>>> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>>>> You know, I should give the error code:
>>>
>>> Compiles perfectly fine in my VS2019.
>>>
>>> The first thought was that it was just another example of the
>>> well-known conflict with Windows' own min/max macros. But regardless
>>> of `NOMINMAX` state, this code compiled without any issues for me.
>>
>> Thanks !
>>
>> I can fix the problem by replacing the
>> std::numeric_limits<size_t>::max(); with UINT_MAX.  But, that is a cheat.
>
> For me is #define-ing NOMIMMAX before including <Windows.h>
> the smarter solution.
>
>

Don't forget WIN32_LEAN_AND_MEAN ... :^)

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9c5bc$2s08n$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=950&group=comp.lang.c%2B%2B#950

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesnimi@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 23:27:24 +0300
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <u9c5bc$2s08n$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me>
<479fe58d-2e17-4fa8-b6fd-8b5e677c990dn@googlegroups.com>
<u9c1d0$2reho$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 20:27:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3688b703d5f9b403e9baa9682a9e90a6";
logging-data="3014935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+w6RKioTM2FAWq5zsHggYwx+hciop1QH4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:11Snw42ZjIerBmSEBv2u6+v3/Ek=
In-Reply-To: <u9c1d0$2reho$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 20 Jul 2023 20:27 UTC

20.07.2023 22:19 Lynn McGuire kirjutas:
> On 7/20/2023 3:53 AM, Malcolm McLean wrote:
>> On Thursday, 20 July 2023 at 03:47:12 UTC+1, Lynn McGuire wrote:
>>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>>
>>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>>
>>> That code worked just fine in Visual C++ 2015. What am I screwing up
>>> here ?
>>>
>>> Thanks,
>>> Lynn
>>>
>> Try
>> static const size_t size_t_max = (std::numeric_limits<size_t>::max)();
>
> Nope, that threw me into std::max hell.  Then I get an error on:
>
>     size_t n = std::max(lhs_size, rhs_size);

This still feels strongly like evil macro abuse. Try

#undef max

before the error points.

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9c5lf$2s08n$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=951&group=comp.lang.c%2B%2B#951

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesnimi@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Thu, 20 Jul 2023 23:32:47 +0300
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <u9c5lf$2s08n$2@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9aqs1$2khmm$1@dont-email.me> <u9c0hh$2r6pq$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 20:32:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3688b703d5f9b403e9baa9682a9e90a6";
logging-data="3014935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XmKiyDzUTvzvH+cO2sk/80KcaP78esxw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:azD1Xy+Ooj/0AddJebVNcO8QA8A=
In-Reply-To: <u9c0hh$2r6pq$4@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Thu, 20 Jul 2023 20:32 UTC

20.07.2023 22:05 Lynn McGuire kirjutas:
> On 7/20/2023 3:22 AM, Paavo Helde wrote:
>> 20.07.2023 05:48 Lynn McGuire kirjutas:
>>> On 7/19/2023 9:46 PM, Lynn McGuire wrote:
>>>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>>>
>>>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>>>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>>>
>>>> That code worked just fine in Visual C++ 2015.  What am I screwing
>>>> up here ?
>>>>
>>>> Thanks,
>>>> Lynn
>>>
>>> You know, I should give the error code:
>>>
>>> Severity    Code    Description    Project    File    Line
>>> Suppression State
>>> Error    C2440    'initializing': cannot convert from 'unsigned int
>>> (__cdecl *)(void) noexcept' to 'fem::size_t'    dii_c_library
>>> C:\dii\inc\fem\size_t.hpp    12
>>
>>
>> This complains about converting a function to an integer. The
>> following line would emit the same error:
>>
>> static const size_t size_t_max = std::numeric_limits<size_t>::max;
>>
>> Suspecting either you did not post the actual failing code, or there
>> is some evil macro hackery going on. To figure that out, hover the
>> mouse over 'max', or right-click on it and select 'go to definition'.
>
> I get the following "limits" code for min and max.
>
> template <>
> class numeric_limits<unsigned int> : public _Num_int_base {
> public:
>     _NODISCARD static constexpr unsigned int(min)() noexcept {
>         return 0;
>     }
>
>     _NODISCARD static constexpr unsigned int(max)() noexcept {
>         return UINT_MAX;
>     }

This is the correct definition which ought to be used. Incidentally,
this shows MS is also protecting itself from evil macro hackery (mostly
caused by MS itself), by placing min and max in parens.

In general, if Visual Studio is acting weird, sometimes it might be
helpful to Rebuild All, and/or to even delete the .vs folder where it
caches a lot of things.

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9crs1$33dlg$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=954&group=comp.lang.c%2B%2B#954

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Fri, 21 Jul 2023 04:51:48 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u9crs1$33dlg$1@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me> <u9agrn$2ir45$1@dont-email.me>
<u9bf9l$2o5nj$1@dont-email.me> <u9c3k8$2rpbs$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 21 Jul 2023 02:51:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="eab0bdde3d4fe538e58ee7a8d92b7e3b";
logging-data="3258032"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zIb6yGoBIPnCiQB4Nd3vCe7n8isH3wDU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:5C1yP1Zkdb0K5wK5zAOHM0NhoIk=
Content-Language: de-DE
In-Reply-To: <u9c3k8$2rpbs$3@dont-email.me>
 by: Bonita Montero - Fri, 21 Jul 2023 02:51 UTC

Am 20.07.2023 um 21:57 schrieb Chris M. Thomasson:
> On 7/20/2023 7:11 AM, Bonita Montero wrote:
>> Am 20.07.2023 um 07:31 schrieb Lynn McGuire:
>>> On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
>>>> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>>>>> You know, I should give the error code:
>>>>
>>>> Compiles perfectly fine in my VS2019.
>>>>
>>>> The first thought was that it was just another example of the
>>>> well-known conflict with Windows' own min/max macros. But regardless
>>>> of `NOMINMAX` state, this code compiled without any issues for me.
>>>
>>> Thanks !
>>>
>>> I can fix the problem by replacing the
>>> std::numeric_limits<size_t>::max(); with UINT_MAX.  But, that is a
>>> cheat.
>>
>> For me is #define-ing NOMIMMAX before including <Windows.h>
>> the smarter solution.
>>
>>
>
> Don't forget  WIN32_LEAN_AND_MEAN ... :^)

That's 100ms difference when compiling for me (7950X).

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<3QmuM.11816$X02a.1180@fx46.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=955&group=comp.lang.c%2B%2B#955

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx46.iad.POSTED!not-for-mail
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Newsgroups: comp.lang.c++
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ama3$2jo7l$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
MIME-Version: 1.0
In-Reply-To: <u9ama3$2jo7l$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 116
Message-ID: <3QmuM.11816$X02a.1180@fx46.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Fri, 21 Jul 2023 03:20:31 UTC
Date: Thu, 20 Jul 2023 23:20:21 -0400
X-Received-Bytes: 4600
 by: Pavel - Fri, 21 Jul 2023 03:20 UTC

Alf P. Steinbach wrote:
> On 2023-07-20 4:48 AM, Lynn McGuire wrote:
>> On 7/19/2023 9:46 PM, Lynn McGuire wrote:
>>> And Visual C++ 2019 is having a hissy fit over these two lines of code:
>>>
>>> static const size_t size_t_max = std::numeric_limits<size_t>::max();
>>> static const ssize_t ssize_t_max = std::numeric_limits<ssize_t>::max();
>>>
>>> That code worked just fine in Visual C++ 2015.  What am I screwing up
>>> here ?
>>>
>>> Thanks,
>>> Lynn
>>
>> You know, I should give the error code:
>>
>> Severity    Code    Description    Project    File    Line Suppression
>> State
>> Error    C2440    'initializing': cannot convert from 'unsigned int
>> (__cdecl *)(void) noexcept' to 'fem::size_t'    dii_c_library
>> C:\dii\inc\fem\size_t.hpp    12
>>
>> And here is the file:
>>
>> #ifndef FEM_SIZE_T_HPP
>> #define FEM_SIZE_T_HPP
>>
>> #include <limits>
>> #include <cstddef>
>>
>> namespace fem {
>>
>>    typedef std::size_t size_t;
>>    typedef std::ptrdiff_t ssize_t;
>>
>>    static const size_t size_t_max = std::numeric_limits<size_t>::max();
>>    static const ssize_t ssize_t_max =
>> std::numeric_limits<ssize_t>::max();
>>
>>    template <typename T>
>>    struct array_of_2
>>    {
>>      T elems[2];
>>
>>      array_of_2() {}
>>
>>      array_of_2(T const& i, T const& j) { elems[0] = i; elems[1] = j; }
>>    };
>>
>>    typedef array_of_2<size_t> size_t_2;
>>    typedef array_of_2<ssize_t> ssize_t_2;
>>
>> } // namespace fem
>>
>> #endif // GUARD
>
> I can't see anything technically wrong and it compiles fine with current
> Visual C++ and g++.
>
> Not what you're asking but note that
>
> * `typedef` is old C syntax, modern `using` can be more clear.
Any code is written to be read by humans. Uniform hurts the readability,
specific improves it. Plus, using declaration make the reader read more
tokens. Upshot: use typedef where you can and using where you can't.

> * `const` at namespace scope implies `static`, i.e. no need to repeat.
Another change from more to less readable code. In order to know a
declaration is in a namespace, one has to either keep this in mind or
look up. The former is inefficient in space, the latter -- in time.
Upshot: feel free to be helpful and use static.

Morale: a new shiny multitool is not a universally good replacement for
the old good pliers.

> * `array_of_2` won't work for T that's not default constructible.
>
> Here's re-styling of the code with the above 3 points addressed:
>
>     #pragma once
>     #include <limits>       // std::numeric_limits
>     #include <utility>      // std::move
>     #include <cstddef>      // std::(size_t, ptrdiff_t)
>
>     namespace fem {
>         using   std::numeric_limits,
>                 std::move;
>
>         using size_t    = std::size_t;
>         using ssize_t   = std::ptrdiff_t;
>
>         template< class Type >
>         constexpr Type max_ = numeric_limits<Type>::max();
>
>         constexpr size_t  size_t_max  = max_<size_t>;
>         constexpr ssize_t ssize_t_max = max_<ssize_t>;
>
>         template< class T >
>         struct array_of_2_
>         {
>             T elems[2];
>
>             array_of_2_() {}
>             array_of_2_( T a, T b ): elems{ move( a ), move( b ) } {}
>         };
>
>         using size_t_2    = array_of_2_<size_t> ;
>         using ssize_t_2   = array_of_2_<ssize_t> ;
>     } // namespace fem
>
> - Alf
>
>

Cheers,
-Pavel

Re: Visual C++ 2019 is having a hissy fit over these two lines of code

<u9eo25$3dia8$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=958&group=comp.lang.c%2B%2B#958

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Visual C++ 2019 is having a hissy fit over these two lines of
code
Date: Fri, 21 Jul 2023 12:59:00 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <u9eo25$3dia8$2@dont-email.me>
References: <u9a76v$2hd12$1@dont-email.me> <u9a7al$2hd12$2@dont-email.me>
<u9ae7q$2ibn8$1@dont-email.me> <u9agrn$2ir45$1@dont-email.me>
<u9bf9l$2o5nj$1@dont-email.me> <u9c3k8$2rpbs$3@dont-email.me>
<u9crs1$33dlg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 21 Jul 2023 19:59:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d3af8303933c1c439d85ae0d3051a74d";
logging-data="3590472"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MnLyj5WlcnngjOsWA9ciGysoRRw4nIJY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:euSQj1iaSxEI43YIeD4C/3yseQA=
Content-Language: en-US
In-Reply-To: <u9crs1$33dlg$1@dont-email.me>
 by: Chris M. Thomasson - Fri, 21 Jul 2023 19:59 UTC

On 7/20/2023 7:51 PM, Bonita Montero wrote:
> Am 20.07.2023 um 21:57 schrieb Chris M. Thomasson:
>> On 7/20/2023 7:11 AM, Bonita Montero wrote:
>>> Am 20.07.2023 um 07:31 schrieb Lynn McGuire:
>>>> On 7/19/2023 11:46 PM, Andrey Tarasevich wrote:
>>>>> On 07/19/23 7:48 PM, Lynn McGuire wrote:
>>>>>> You know, I should give the error code:
>>>>>
>>>>> Compiles perfectly fine in my VS2019.
>>>>>
>>>>> The first thought was that it was just another example of the
>>>>> well-known conflict with Windows' own min/max macros. But
>>>>> regardless of `NOMINMAX` state, this code compiled without any
>>>>> issues for me.
>>>>
>>>> Thanks !
>>>>
>>>> I can fix the problem by replacing the
>>>> std::numeric_limits<size_t>::max(); with UINT_MAX.  But, that is a
>>>> cheat.
>>>
>>> For me is #define-ing NOMIMMAX before including <Windows.h>
>>> the smarter solution.
>>>
>>>
>>
>> Don't forget  WIN32_LEAN_AND_MEAN ... :^)
>
> That's 100ms difference when compiling for me (7950X).
>

:^) Still, its something that was ingrained in my brain from long ago.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor