Boost logo

Boost Users :

Subject: [Boost-users] function template with a universal reference to a specific type
From: Ireneusz Szcześniak (irek.szczesniak_at_[hidden])
Date: 2018-12-30 15:04:27


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>
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 i = 1;
   const int ci = 1;

In my code I need to provide different implementations of foo for
different types (and these types are templated). How can I accomplish


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at