Project scenario:
The error information reported during project code compilation is as follows:
error: non-const lvalue reference to type '...' cannot bind to a value of unrelated type '...'
Problem Description:
After the project problem is simply abstracted, it is equivalent to the following problems:
Do this and compile through
int a;
const double& m = a;
However, an error is reported in this compilation
int a;
double& m = a;
Error information such as title
Cause analysis:
Because temporary variables cannot be bound to a non const reference
double& m = a;
a
is an int variable that will be implicitly converted to a double variable, so this process generates a temporary variable. Non const reference cannot bind temporary variables
Solution:
Avoid implicit conversion or add const
Read More:
- Sending ‘const NSString *__strong‘ to parameter of type ‘NSString *‘ discards qualifiers
- Unity Error:InvalidCastException: Cannot cast from source type to destination type.
- Undefined reference to ‘CV:: imread (CV:: String const & int)’
- Error type referred to is not an annotation type:RedisCache
- Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
- After introducing sass into Vue project, start to report error typeerror [err]_ INVALID_ ARG_ Type]: the “path” argument must be of type string
- Error tips:array type has incomplete element type
- No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.la
- Error: property ‘TZ’ does not exist on type ‘type of moment’
- On the usage of ‘ref.stor.type search’ field in SAP WM movement type
- Es error mapper of different type, current_ Type “text” solution
- Ima tag error HTML, microsoft.mshtml.dll add reference and type selection error solution
- array type has an incomplete element type
- Error: (22,57) Java: type parameter… Mapper is not in the range of type variable M
- C# Member XXX cannot be accessed with an instance with an instance reference;qualify it with a type
- [Solved] RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1‘
- Enum type and set type of MySQL
- Type error: cannot unpack non Iterable non type object appears when starting Bert server in Ubuntu system
- Type definition error – one of the causes of type definition errors is WM in Oracle_ Concat function usage
- Element ‘dependency‘ cannot have character [children], because the type‘s content type is element-on