|
Boost Users : |
Subject: Re: [Boost-users] function template with a universal reference to a specific type
From: Ireneusz SzczeÅniak (irek.szczesniak_at_[hidden])
Date: 2018-12-31 08:01:11
Thank you for the advice!
On 30.12.2018 17:16, Good Guy via Boost-users wrote:
> I don't know answer to your question but if you want to know about
> another generic C++ newsgroup then you can try this:
>
> <news://nntp.aioe.org/comp.lang.c++>
>
> It is very active but like any unmoderated newsgroups, you can expect
> the thread to drift away from the main question.
>
> Good luck and a very Happy & Prosperous New Year
>
> On 30/12/2018 15:04, Ireneusz SzczeÅniak via Boost-users wrote:
>> Hi,
>>
>> I'm writing to ask a C++ question, not specifically Boost-related,
>> but this list is the best place I know.
>>
>> How can I write a function template, which has a parameter of the
>> universal reference to a specific type?
>>
>> I can write a function template like this:
>>
>> template <typename T>
>> void
>> foo(T &&t)
>> {
>> Â // The primary template implementation.
>> Â cout << "Primary: " << __PRETTY_FUNCTION__ << endl;
>> }
>>
>> And so I can call this function with an expression of any value
>> category, and any type, cv-qualified or not, like this:
>>
>> int
>> main()
>> {
>> Â foo(1);
>> Â int i = 1;
>> Â foo(i);
>> Â const int ci = 1;
>> Â foo(ci);
>> }
>>
>> In my code I need to provide different implementations of foo for
>> different types (and these types are templated). How can I
>> accomplish that?
>>
>>
>> Best,
>> Irek
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net