468,456 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

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 6230
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Buster Copley | last post: by
7 posts views Thread by Vaca Louca | last post: by
3 posts views Thread by Capstar | last post: by
2 posts views Thread by Drew McCormack | last post: by
3 posts views Thread by aiooua | last post: by
2 posts views Thread by Joe Hesse | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.