Intellij idea 2016 invalid incompatible type - intellij-idea-2016

Intellij idea reports a compile error: incompatible types. However the groups variable on the left of that equation is defined exactly as com.example.intepipe.model.Groups. I have already tried invalid caches and restart

Related

error: ‘HAAR_DO_CANNY_PRUNING’ is not a member of ‘cv’

I am upgrading an existing code base that use OpenCV 2 and 3 to be compatible with my Ubuntu 20.04 that uses OpenCV 4. One error I encountered when compiling is:
error: ‘HAAR_DO_CANNY_PRUNING’ is not a member of ‘cv’; did you mean ‘CASCADE_DO_CANNY_PRUNING’?
Should I accept the change proposed by the compiler and change cv::HAAR_DO_CANNY_PRUNING to cv::CASCADE_DO_CANNY_PRUNING for all occurrences?
Should I accept the change proposed by the compiler?
Yes.
The values of the 4 CASCADE_* symbols match the ones of the old HAAR_* symbols, as #DanMasek commented.
You can check the enums in Enumeration Type Documentation and OpenCV-2_2 Reference, page 795.

Need some help about "swap" function in c++

I am new to C++ programming. I am trying to compile another person's program, and the software reported a bug that I don't know how to solve (the software I use is Visual Studio 2019).
The line of code with bug is:
swap(allBeamPoints, unordered_map<int, vector<LidarPoint>>());
The definition for variable allBeamPoints is:
unordered_map<int, vector<LidarPoint>>allBeamPoints
The error information is:
Error C2665 'std::swap': none of the 2 overloads could convert all the argument types
and
Error (active) E0304 no instance of overloaded function "swap" matches the argument list
However, if I type the following codes, no bug will be reported:
unordered_map<int, vector<LidarPoint>> allBeamPoints_new;
swap(allBeamPoints, allBeamPoints_new);
Does anyone know what the problem is? Did I fail to link some of the required libraries? How should I check those libraries?
The older MSVC compilers allowed the binding of an anonymous temporary to a non-const reference function parameter. That's not standard C++.
So
swap(allBeamPoints, unordered_map<int, vector<LidarPoint>>());
which had the effect of clearing allBeamPoints was reasonably idiomatic in code that only targeted Microsoft platforms.
It's wrong and not portable as you now observe. Use
allBeamPoints.clear();
instead to clear the map. Your second snippet compiles since allBeamPoints_new is not an anonymous temporary.

What does the "Expected '(' for function-style cast or type construction" error mean?

I'm getting the error "Expected '(' for function-style cast or type construction", and have done my best to research the meaning of this error online, but have been unable to find any documentation of what causes this error.
All the related questions on Stack Overflow that I have found bug fix a specific code snippet and do not explain more generally what is causing the error.
These include
Expected '(' for function-style cast or type construction answer highlights several issues with the code. Which issue is actually causing the error is unclear.
c++ Xcode expected '(' for function-style cast or type construction defines functions inside a main function. This seems like a clear syntax problem, but why this specific error is produced is still unclear to me.
'(' for function-style cast or construction type Xcode error. In this last example, the OP calls a function in a way that looks very similar to a function declaration, plus they declare a function with the same name but a different signature. Based on where the error is thrown and the message from the error, it seems that the error has something to do with function declarations.
Can I get a documentation-style answer that translates what "function-style cast" and "type construction" mean in simple english? When does the compiler choose to throw this error instead of some other error?
I don't want an answer that is specific to my own error, but as requested, here is my MCVE
#include <boost/integer_traits.hpp>
class Test{
const double MAX_DEPTH_VAL = (double) boost::integer_traits<unsigned short>.const_max;
const double MIN_DEPTH_VAL = (double) boost::integer_traits<unsigned short>.const_max;
};
I was led to believe that this syntax was possible, by this answer https://stackoverflow.com/a/2738576/3303546
This is a syntax error. Now, non-programmers or amateurs might hear the term syntax error and equate it with a general bug. But in C++ (and other languages) it has a more specific meaning.
There is a language grammar which is a set of rules by which the compiler, at an early stage of translation, breaks up the source code into logical groups. This is before any meaning is ascribed to those groups (that part is sometimes called semantic checking).
The syntax error you saw means that the compiler could not match up the source code to the grammar rules for C++. Precisely because it could not do this -- it's hard for the compiler to know what the programmer intended. So, syntax error messages are often guesses or don't relate to the programmer intention.
When you see this error, the compiler is suggesting a way of changing the code that would possibly match one of the grammar rules, but that may or may not actually be a good fix in the situation.
So, you can treat this sort of error just as "general syntax error", not worrying too much about the details of the error. To fix it, go back to simpler expressions that you are sure are not syntax errors, and then build up towards what you wanted to write.
An analogy for English language might be the sentence "I the room went of". Imagine some language translation software. This doesn't match any known sentence structure but what error message can it report? The actual suggestions probably won't help you to fix the sentence.
In your specific example, there is a syntax error. The g++ error message is different:
error: expected primary-expression before '.' token
where primary-expression is an entry in the C++ grammar. g++ sees the . token and assumes you mean the member access operator. But the grammar says that the left-hand operand of the member access operator must be a primary-expression (and the semantic rules say that this primary-expression denotes the object whose member you want to access).
However in your actual code the left-hand side is (double) boost::integer_traits<unsigned short> which does not match the grammar specification for primary-expression. (In fact it's a type name). The compiler can't proceed any further from here so it bails out.
Your compiler also failed to match the code to any grammar rule, but it guessed you were trying to write a function-style cast or type construction.
"Function-style cast" means code like int(5.0), so perhaps it recognized boost::integer_traits<unsigned short> as a type-name, and it guessed that you meant boost::integer_traits<unsigned short>(const_max), i.e. casting some variable const_max to that type.
I'm not sure what your compiler means by "type construction" here.
NB. If you want to know how to fix the actual code in your question, I'd suggest starting a new question where you post the code and error message and ask how to fix the code.
I fixed this error by adding -std=c++20 in my Makefile.

Type * error in gfortran

When I run my code I get the following error for all the statements that have the following format. Is there any problem with the type statement? If yes kindly provide me with a solution. I running my code on a Ubuntu 14.10 system. The program is very long hence I am not posting it now however if required I can surely send it.
recfunk_ascii.f:622.12:
type *,'enter back-azimuth limits ib1,ib2 (integers!)'
1
Error: Invalid character in name at (1)
Type is an obsolete and completely non-standard statement (see http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbi/index.html). It is not portable because many compilers do not recognize it. It should be changed to a PRINT statement, as #francescalus suggest in the comment.
print *,'enter back-azimuth limits ib1,ib2 (integers!)'

How can Visual Studio use boost::function with /GR- while GCC can't with -fno-rtti?

I recently started porting an application to Android using the NDK and I encountered the following error:
boost/function/function_base.hpp:220: error: cannot use typeid with -fno-rtti.
Ordinarily, I wouldn't think twice about that error, but the visual studio project file set /GR-, which disables RTTI and has no problem using boost::function.
My theory on this is that because typeid is evaulated by the compilier when the static type can be determined, that must be the case for every usage of boost::function in the application. Visual Studio must be attempting to determine the static type first while GCC immediately throws the error on typeid before attempting to evaluate it.
Does that sound right? If not, what is going on?
I'm not booted into my Windows partition, but it was just as simple to look this up in MSDN.
As per this link on MSDN:
If the expression is dereferencing a pointer, and that pointer's value
is zero, typeid throws a bad_typeid exception. If the pointer does not
point to a valid object, a __non_rtti_object exception is thrown,
indicating an attempt to analyze the RTTI that triggered a fault (like
access violation), because the object is somehow invalid (bad pointer
or the code wasn't compiled with /GR).
If the expression is neither a pointer nor a reference to a base class
of the object, the result is a type_info reference representing the
static type of the expression. The static type of an expression refers
to the type of an expression as it is known at compile time.....
In other words, if the expression's type can't be inferred at compile time, and no /GR, then you're going to get an exception or compiler error. But the second paragraph kind of implies it can infer non-ambiguous types at compile time.