Thursday, July 20, 2023

Digest for comp.lang.c++@googlegroups.com - 22 updates in 5 topics

Lynn McGuire <lynnmcguire5@gmail.com>: Jul 19 09:46PM -0500

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
Lynn McGuire <lynnmcguire5@gmail.com>: Jul 19 09:48PM -0500

On 7/19/2023 9:46 PM, Lynn McGuire wrote:
> 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
 

No comments: