Monday, March 13, 2023

Digest for comp.lang.c++@googlegroups.com - 25 updates in 3 topics

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 12 04:52PM -0700

On 3/12/2023 1:16 PM, Chris M. Thomasson wrote:
 
> I don't think there is a native version of MSVC for Linux. They have one
> for the Mac:
 
> https://visualstudio.microsoft.com/vs/mac/
[...]
 
I failed to notice that it is only for .NET
 
God damn it! Sorry. ;^o
Bonita Montero <Bonita.Montero@gmail.com>: Mar 13 05:04AM +0100

Am 12.03.2023 um 23:19 schrieb Mr Flibble:
 
> discarded statements don't have to be compilable for a particular
> template argument; discarded statements are only fully checked outside
> of templates.
 
Of course the code depends on the template parameter. But if this
hasn't a dependent element_type the code is wrong. Use a concepted
if constexpr which embeds the further if and everything is fine.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 13 05:42AM +0100

Am 11.03.2023 um 23:01 schrieb Mr Flibble:
> second attempt at using it and I get a different problem this time for
> which I have raised a defect report:
 
> https://developercommunity.visualstudio.com/t/Problem-with-constexpr-and-accessing-non/10307212
 
Use sth. like that:
 
#include <type_traits>
 
using namespace std;
 
#define WITH_EMBEDDED_TYPE
 
template<typename Type>
void fn( Type t )
{
if constexpr( requires() { { Type::element_type() }; } )
if constexpr( is_scalar_v<typename Type::element_type> )
;
}
 
int main()
{
struct S
{
#if defined(WITH_EMBEDDED_TYPE)
using element_type = int;

No comments: