473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

template: no matching function call. Converting const value to constreference.

template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, const typename
ContainerType::reference, const typename ContainerType::reference);

const BigInteger e(boost::lexical_cast<BigInteger>(rsa_encrypts[2]));
const BigInteger
n(boost::lexical_cast<BigInteger>(rsa_encrypts[1]));
std::string infile(rsa_encrypts[0]);
boost::scoped_ptr<boost::filesystem::ifstreamencry pt_input(new
boost::filesystem::ifstream(infile));
const std::string
plaintext(std::istreambuf_iterator<char>(encrypt_i nput->rdbuf()),
std::istreambuf_iterator<char>());
std::list<BigInteger>
decrypted_list(encryptcpw::rsa_encrypt_list<std::l ist<BigInteger>
>(plaintext, e, n)); // this is line 64.
std::vector<BigInteger>(ciphertext).swap(ciphertex t);
// ... some code in between.
const std::string answer(encryptcpw::rsa_decrypt_list(ciphertext, d,
n)); // this is line 102.
error on gcc:
../cs512/c++/RsaEncrypt.cpp:64: error: no matching function for call to
'rsa_encr
ypt_list(const std::string&, const BigInteger&, const BigInteger&)'
../cs512/c++/RsaEncrypt.cpp:102: error: no matching function for call
to 'rsa_dec
rypt_list(std::vector<BigInteger, std::allocator<BigInteger&, const
BigIntege
r&, const BigInteger&)'
error on msvc:
../cs512/c++/RsaEncrypt.cpp(64) : error C2664:
'encryptcpw::rsa_encrypt_list' : cannot convert parameter 2 from
'const BigInteger' to 'BigInteger &'
Conversion loses qualifiers

Anybody know how to fix this.
Dec 6 '07 #1
2 6542
On Dec 6, 5:12 am, "cablep...@gmail.com" <cablep...@gmail.comwrote:
template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, const typename
ContainerType::reference, const typename ContainerType::reference);

const BigInteger e(boost::lexical_cast<BigInteger>(rsa_encrypts[2]));
const BigInteger
n(boost::lexical_cast<BigInteger>(rsa_encrypts[1]));
std::string infile(rsa_encrypts[0]);
boost::scoped_ptr<boost::filesystem::ifstreamencry pt_input(new
boost::filesystem::ifstream(infile));
const std::string
plaintext(std::istreambuf_iterator<char>(encrypt_i nput->rdbuf()),
std::istreambuf_iterator<char>());
std::list<BigInteger>
decrypted_list(encryptcpw::rsa_encrypt_list<std::l ist<BigInteger>
(plaintext, e, n)); // this is line 64.

std::vector<BigInteger>(ciphertext).swap(ciphertex t);
// ... some code in between.
const std::string answer(encryptcpw::rsa_decrypt_list(ciphertext, d,
n)); // this is line 102.

error on gcc:
./cs512/c++/RsaEncrypt.cpp:64: error: no matching function for call to
'rsa_encr
ypt_list(const std::string&, const BigInteger&, const BigInteger&)'
./cs512/c++/RsaEncrypt.cpp:102: error: no matching function for call
to 'rsa_dec
rypt_list(std::vector<BigInteger, std::allocator<BigInteger&, const
BigIntege
r&, const BigInteger&)'

error on msvc:
./cs512/c++/RsaEncrypt.cpp(64) : error C2664:
'encryptcpw::rsa_encrypt_list' : cannot convert parameter 2 from
'const BigInteger' to 'BigInteger &'
Conversion loses qualifiers

Anybody know how to fix this.
I believe the problem is here:

template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, const typename
ContainerType::reference, const typename ContainerType::reference);

... you can't const-qualify ContainerType::reference; Comeau online
gives warning "warning: type qualifiers are meaningless in this
declaration"

you need instead:
template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, typename
ContainerType::const_reference, typename
ContainerType::const_reference);

and define const_reference in your ContainerType(s) accordingly.
Dec 6 '07 #2
On Dec 6, 5:05 am, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
On Dec 6, 5:12 am, "cablep...@gmail.com" <cablep...@gmail.comwrote:
template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, const typename
ContainerType::reference, const typename ContainerType::reference);
const BigInteger e(boost::lexical_cast<BigInteger>(rsa_encrypts[2]));
const BigInteger
n(boost::lexical_cast<BigInteger>(rsa_encrypts[1]));
std::string infile(rsa_encrypts[0]);
boost::scoped_ptr<boost::filesystem::ifstreamencry pt_input(new
boost::filesystem::ifstream(infile));
const std::string
plaintext(std::istreambuf_iterator<char>(encrypt_i nput->rdbuf()),
std::istreambuf_iterator<char>());
std::list<BigInteger>
decrypted_list(encryptcpw::rsa_encrypt_list<std::l ist<BigInteger>
>(plaintext, e, n)); // this is line 64.
std::vector<BigInteger>(ciphertext).swap(ciphertex t);
// ... some code in between.
const std::string answer(encryptcpw::rsa_decrypt_list(ciphertext, d,
n)); // this is line 102.
error on gcc:
./cs512/c++/RsaEncrypt.cpp:64: error: no matching function for call to
'rsa_encr
ypt_list(const std::string&, const BigInteger&, const BigInteger&)'
./cs512/c++/RsaEncrypt.cpp:102: error: no matching function for call
to 'rsa_dec
rypt_list(std::vector<BigInteger, std::allocator<BigInteger&, const
BigIntege
r&, const BigInteger&)'
error on msvc:
./cs512/c++/RsaEncrypt.cpp(64) : error C2664:
'encryptcpw::rsa_encrypt_list' : cannot convert parameter 2 from
'const BigInteger' to 'BigInteger &'
Conversion loses qualifiers
Anybody know how to fix this.

I believe the problem is here:

template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, const typename
ContainerType::reference, const typename ContainerType::reference);

.. you can't const-qualify ContainerType::reference; Comeau online
gives warning "warning: type qualifiers are meaningless in this
declaration"

you need instead:
template <typename ContainerType>
ContainerType rsa_encrypt_list(const std::string&, typename
ContainerType::const_reference, typename
ContainerType::const_reference);

and define const_reference in your ContainerType(s) accordingly.
thanks that fixes everything.
Dec 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Buster Copley | last post by:
Compiling the following code gives rise to the error indicated. template <typename T, int N> void f (const T (& u) ) { } void g (const int (& u) ) { } int main () { int x ; f (x); // ERROR...
7
by: Vaca Louca | last post by:
Hello, My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3. (the other system is Windows XP with MS Visual Studio .NET 2003) I have an auto_array<T> template (based on a template taken from...
3
by: Capstar | last post by:
Hi NG, I am trying to get the attached piece of code to work, but I can't figure out what I'm doing wrong. To me it seems that when I don't pass an argument to x::do_something, it should use the...
2
by: Drew McCormack | last post by:
I have a self written Tensor class which I need to write a number of elementwise operations for (eg sin, cos, abs, conj). I am trying to implement most of these in terms of standard library...
12
by: aaragon | last post by:
Hello all. I have a simple question that seems trivial but I can't make it to work. I have a class that takes as a template argument, another class. The idea is as follows: #include...
3
by: aiooua | last post by:
Any idea why the following code does not compile? ---- #include<iostream> #include<list> using namespace std; class Base { public: int val;
2
by: Joe Hesse | last post by:
Hi, I have a template class and I want to define an operator << as a friend function. For each instantiation of the class I want a corresponding instantiation of operator <<. The following...
1
by: Ali | last post by:
The code at the end of this message works just fine with M$ VS2005 but with g++ 4.1.3 i get this: node.cpp: In function ‘int main()’: node.cpp:96: error: no matching function for call to...
3
by: JanW | last post by:
Somewhat a C++ beginner, I'm trying to make a general test function that could test unary operators (or methods) of an object of any class. Arguments are a member-pointer to the function, a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.