액세스 차원의 후원 멀티-C++에서 배열

0

질문

을 실행할 때 다음과 같은 경고와 함께 플래그를 나는 형식 변환 경고입니다.

#include <boost/multi_array.hpp>

void function (boost::multi_array<unsigned char, 2> matrix) {
  int nrows = matrix.shape()[0];
  int ncols = matrix.shape()[1];
}

보고 경고 메시지가 아래. 이 뜻은 내가 암시적으로 변환하'오 unsigned int'일반'int'?

그렇다면,내 생각에 이것은 내가 원하는 무엇인가(필요한 계산을 수행하으로 nrows,ncols 나),그리고 그래서 내가 어떻게 변환 explicit?

image.cpp:93:32: warning: conversion to ‘int’ from ‘boost::const_multi_array_ref<float, 2ul, float*>::size_type {aka long unsigned int}’ may alter its value [-Wconversion]
     int nrows = matrix.shape()[0];
boost c++
2021-11-20 23:46:16
1

최고의 응답

1

이 뜻은 내가 암시적으로 변환하'오 unsigned int'일반'int'?

네,그것이 무엇을 의미.

당신이 원하지 않는 경우 경고 다음에 만들지 않는 nrowsncols 유형 int. 가장 쉬운 일이지만 컴파일러를 추론 형식 즉

auto nrows = matrix.shape()[0];
auto ncols = matrix.shape()[1];

나 만들 수 있습니다 그들의 유형 size_t는 표준 라이브러리를 사용한 크기의 컨테이너지를 방출합니다.

2021-12-04 22:35:52

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................