Creating lvalue reference to const allows binding lvalue reference to non-modifiable, modifiable, and rvalues. If we can make parameter as const reference type, we can bind argument of any type. For example,

#include <string>
#include <iostream>
 
void printString(const std::string &value)
{
    std::cout << value << "\n";
}
 
int main(int argc, char const *argv[])
{
    printString("Hello world");
    return 0;
}

Now we can pass rvalue "Hello world". The calling syntax becomes same as calling a normal function.

We can pass arguments of any type as long as type of value can be implicitly convertible to reference type, as noted in const references.

Warning

Creating a const lvalue reference and binding of to a value of different type leads compiler to create a temporary object and copying the value into the temporary object. So, if passing by reference with different data type can cause a copy which can be suboptimal.

So make sure to match the type of value with the reference type.

References

  1. https://www.learncpp.com/cpp-tutorial/pass-by-const-lvalue-reference/