473,403 Members | 2,183 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,403 software developers and data experts.

declaring non-template friend functions

Hello everybody,

When I try to declare nontemplate friend functions I get the following warning:

[warning] friend decleration......declares a non-template function
[warning] (if this is not what you intended, make sure the function tempate has already been declared and add<> after the function name here)-Wno-non-template-friend disables this warning.

Since declaring a non-template friend function is what i have intended, I would like to disable this warning. But I do not know how to do this. Where in my program am i going to write "-Wno-non-template-friend"?
Jun 24 '07 #1
1 2012
weaknessforcats
9,208 Expert Mod 8TB
You need an explicit specializtion of your template:
Expand|Select|Wrap|Line Numbers
  1. template <class T>
  2. void MyFunc(T& arg)
  3. {
  4.    //etc
  5. }
  6.  
  7. template<> void MyFunc(string& in);  //explicit specialization
  8.  
The explicit specialization tells the compiler to not use the template if the T is a string. That is, it means you have coded a non-template function because the template won't work if T is a string.

Try not to make warnings go away. If the compiler thinks there's a problem, then, almost certainly, there is a problem.

None of this has anything to do with whethe the function is a friend or not.
Jun 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jim Hudon | last post by:
i need to create an array of a size determined by a non-const variable: int char sampleArray; why does the following not work, and what can i do: const int constArraySize = arraySize; int...
5
by: Generic Usenet Account | last post by:
I am trying to compile the following sample code: class WhatISHappeningHere { static const int x = 32; static const char* yy = "Howdy"; // ... // blah blah blah // ... };
6
by: Steve Jorgensen | last post by:
Many of the regulars here have explained that declaring variables using As New .... is a bad idea, and some have given some good explanations, but I wanted add one more demonstration to the mix. ...
1
by: Maarten Terlingen | last post by:
Sample: ClassA: ClassB ClassB: ClassC ClassA x = new Class C I want to know the declaring type of C. x.GetType() returns C x.GetType().BaseType returns B x.GetType().BaseType.BaseType...
20
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
18
by: Nathan | last post by:
If you're wondering why I post so many questions, it's because I want to make an entry in the Guinness Book of World Records. But because I post so many, I try to make them simple. Here is (I...
5
by: param | last post by:
Declaring struct as static is creating problem with newer version of CC compiler 5.7 in solaris. e.g. static struct new_str { int a; int b; };
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
24
by: Daniel Rudy | last post by:
Hello Group, Consider the following code: /* form 1 */ int main(void) { int i; char *p;
8
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine,...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.