473,804 Members | 3,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

const BigInteger e(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[2]));
const BigInteger
n(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[1]));
std::string infile(rsa_encr ypts[0]);
boost::scoped_p tr<boost::files ystem::ifstream encrypt_input(n ew
boost::filesyst em::ifstream(in file));
const std::string
plaintext(std:: istreambuf_iter ator<char>(encr ypt_input->rdbuf()),
std::istreambuf _iterator<char> ());
std::list<BigIn teger>
decrypted_list( encryptcpw::rsa _encrypt_list<s td::list<BigInt eger>
>(plaintext, e, n)); // this is line 64.
std::vector<Big Integer>(cipher text).swap(ciph ertext);
// ... some code in between.
const std::string answer(encryptc pw::rsa_decrypt _list(ciphertex t, 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<BigInteg er, std::allocator< BigInteger&, const
BigIntege
r&, const BigInteger&)'
error on msvc:
../cs512/c++/RsaEncrypt.cpp( 64) : error C2664:
'encryptcpw::rs a_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 6569
On Dec 6, 5:12 am, "cablep...@gmai l.com" <cablep...@gmai l.comwrote:
template <typename ContainerType>
ContainerType rsa_encrypt_lis t(const std::string&, const typename
ContainerType:: reference, const typename ContainerType:: reference);

const BigInteger e(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[2]));
const BigInteger
n(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[1]));
std::string infile(rsa_encr ypts[0]);
boost::scoped_p tr<boost::files ystem::ifstream encrypt_input(n ew
boost::filesyst em::ifstream(in file));
const std::string
plaintext(std:: istreambuf_iter ator<char>(encr ypt_input->rdbuf()),
std::istreambuf _iterator<char> ());
std::list<BigIn teger>
decrypted_list( encryptcpw::rsa _encrypt_list<s td::list<BigInt eger>
(plaintext, e, n)); // this is line 64.

std::vector<Big Integer>(cipher text).swap(ciph ertext);
// ... some code in between.
const std::string answer(encryptc pw::rsa_decrypt _list(ciphertex t, 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<BigInteg er, std::allocator< BigInteger&, const
BigIntege
r&, const BigInteger&)'

error on msvc:
./cs512/c++/RsaEncrypt.cpp( 64) : error C2664:
'encryptcpw::rs a_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_lis t(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_lis t(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...@gmai l.com" <cablep...@gmai l.comwrote:
template <typename ContainerType>
ContainerType rsa_encrypt_lis t(const std::string&, const typename
ContainerType:: reference, const typename ContainerType:: reference);
const BigInteger e(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[2]));
const BigInteger
n(boost::lexica l_cast<BigInteg er>(rsa_encrypt s[1]));
std::string infile(rsa_encr ypts[0]);
boost::scoped_p tr<boost::files ystem::ifstream encrypt_input(n ew
boost::filesyst em::ifstream(in file));
const std::string
plaintext(std:: istreambuf_iter ator<char>(encr ypt_input->rdbuf()),
std::istreambuf _iterator<char> ());
std::list<BigIn teger>
decrypted_list( encryptcpw::rsa _encrypt_list<s td::list<BigInt eger>
>(plaintext, e, n)); // this is line 64.
std::vector<Big Integer>(cipher text).swap(ciph ertext);
// ... some code in between.
const std::string answer(encryptc pw::rsa_decrypt _list(ciphertex t, 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<BigInteg er, std::allocator< BigInteger&, const
BigIntege
r&, const BigInteger&)'
error on msvc:
./cs512/c++/RsaEncrypt.cpp( 64) : error C2664:
'encryptcpw::rs a_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_lis t(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_lis t(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
3399
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 g (x);
7
5087
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 the Corona project hosted at SourceForge) which basically wants to implement std::auto_ptr<T> semantics for an array.
3
2754
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 default value, which is always_true(). but gcc says: no matching function for call to `x::do_something()' and msvs says: could not deduce template argument for '_Tp'
2
1775
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 functions. Unfortunately, not all functions in the standard library are constructed the same (eg some are template functions, some use pass-by-value where others use pass by reference). To get around this, I have tried to come up with an adaptor...
12
2331
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 <iostream> using namespace std; template <class ClassB> class ClassA
3
2226
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
1935
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 example fails to compile with g++ version 4.1.2. I would appreciate it if you could help me fix it or point me to a suitable reference. Thank you,
1
1920
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 ‘bnode<cxsc::interval>::bnode(cxsc::interval*, cxsc::interval*, <unresolved overloaded function type>)’ node.cpp:38: note: candidates are: bnode<T>::bnode(const T*, const T*, T (*)(const T&, const T&)) node.cpp:34: note: ...
3
1591
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 single input argument of some type for that function, and the expected result of some type. Then it tests if the result is as expected, and does some logging of the results (pass, fail) etc. Well, the template "mess" does not quite work out.
0
10567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.