narrowing Questions
3
Solved
In the below code:
final int a;
a=2;
byte b=a; // error: possible loss of precision
Why do I get this error? Isn't a final variable compile time constant expression and hence implicitly narrowed...
Mckinnon asked 11/6, 2015 at 15:33
2
Solved
I am trying to write a simple stateless sesssion bean but I have problem with narrow reference I give in lookup time.
I got
class cast exeption
I use
eclipse IDE
my bean class
package ...
2
Solved
In Java < 8, returning "unsafe" objects (objects or null), I was able to specialize return type in subclass:
class A {}
class B extends A {}
interface Sup { A a(); /* returns A instance, or nul...
Pipsqueak asked 25/4, 2015 at 19:13
1
Solved
I am writing a unit test checking some binary data against an expected array. The expected array in question is just some series of bytes, doesn't matter specifically:
char expected[] = {0x42, 0xd...
2
Solved
g++ 4.9.0
-O2 -std=c++11
template<class T>
struct vec3 {
T x, y, z;
vec3() = default;
vec3(const vec3<T> &other) = default;
vec3(T xx, T yy, T zz) { x = xx; y = yy; z = zz; }
...
1
Solved
Consider this piece of C++11 code:
#include <iostream>
struct X
{
X(bool arg) { std::cout << arg << '\n'; }
};
int main()
{
double d = 7.0;
X x{d};
}
There's a narrowing ...
Priapic asked 16/12, 2014 at 14:51
4
Solved
I try to compile the following code with gcc and C++11 enabled:
unsigned int id = 100;
unsigned char array[] = { id % 3, id % 5 };
I get these warnings:
narrowing conversion of ‘(id % 3u)’ fr...
0
The following
int i = 0;
double d{i};
gives an error (in clang) or warning (in gcc) of a narrowing conversion from 'int' to 'double'. I found it amazing that this is really narrowing, at least u...
Jempty asked 23/3, 2014 at 18:10
3
Solved
This expression can be found in the Example in §8.5.4/7 in the Standard (N3797)
unsigned int ui1 = {-1}; // error: narrows
Given §8.5.4/7 and its 4th bullet point:
A narrowing conversion is a...
Exalted asked 20/1, 2014 at 19:4
2
Solved
Using the {} initializer in C++11 to initialize bool b = {2} yields the following warning message:
warning: narrowing conversion of ‘2’ from ‘int’ to ‘bool’ inside { } [-Wnarrowing]
However, usi...
Passmore asked 2/11, 2013 at 1:16
4
Solved
for some reason I'm getting the following warning
filename.cpp:99:53: warning: narrowing conversion of ‘sin(((double)theta))’ from ‘double’ to ‘float’ inside { } [-Wnarrowing]
filename.cpp:99:66: ...
1
The following program compiles without errors or warning with gcc 4.8.1,
-Wall -std=c++11:
template<unsigned N>
struct A{};
int main(){
A<1-2> a;
(void)a;
return 0;
}
clang 3.3 w...
Tormentor asked 9/7, 2013 at 22:8
1
Solved
The Standard at § 8.5.4/7 explains what a narrowing conversion is:
A narrowing conversion is an implicit conversion
— from a floating-point type to an integer type, or
— from long double to double...
Infringement asked 9/7, 2013 at 14:59
1
In it's current version, is it possible to use Bing's "Narrow By Date" feature when accessing it's API?
I cannot find any information about how to narrow the results such that it only shows result...
Tenter asked 2/10, 2011 at 4:21
1
Solved
Since switching on the C++0x standard in g++, I've started seeing 'narrowing conversion' errors, particularly when converting from an 'int' to a 'short' although I understand the error covers a muc...
3
Solved
I'd like to pass some numeric byte values via an initializer list a variadic template into an array. Is that possible?
template < int N > struct a {
char s[N];
template < typename ... A...
1
Solved
I find the narrow-to-region command useful, however it applies to the buffer and not to the current window.
I'd like to have one window display a narrowed version of the buffer, while the buffer i...
© 2022 - 2024 — McMap. All rights reserved.