[RESOLVED] a type (typename) as a parameter of a function
Hi! May be somebody could explain or give a reference on how to use a type as a function parameter. I am using the deal.II library. There is next member function there:
Code:
template<int dim>
template<typename InputVector, class DH>
static void KellyErrorEstimator< dim >::estimate(const Mapping< dim > & mapping,
const DH & dof,
const Quadrature< dim-1 > & quadrature,
const typename FunctionMap< dim >::type & neumann_bc,
const InputVector & solution,
Vector< float > & error,
const std::vector< bool > & component_mask = std::vector< bool >(),
const Function< dim > * coefficients = 0,
const unsigned int n_threads = multithread_info.n_default_threads,
const unsigned int subdomain_id = numbers::invalid_unsigned_int,
const unsigned int material_id = numbers::invalid_unsigned_int
) [inline, static]
For my question parameter const typename FunctionMap< dim >::type & neumann_bc is important. The declaration of its type is
Code:
typedef std::map<unsigned char, const Function<dim>*> FunctionMap< dim >::type
I undestand it as the reference to the name of the type is given to the function as a parameter. Is it possible to use a type or its reference as a parameter? This structure is compiled perfectly in the next configuration
Code:
typename FunctionMap<dim>::type neumann_boundary;
KellyErrorEstimator<dim>::estimate (dof_handler, dealii::QGauss<dim-1>(feq1+1), neumann_boundary, solution, estimated_error_per_cell);
Here we are creating an object neumann_boundary of the type "type map".
However, if i change it to
Code:
typedef FunctionMap<dim>::type neumann_boundary;
or
Code:
typedef typename FunctionMap<dim>::type neumann_boundary;
i got an error. So, what's going on when one transfers to a function a type as a parameter?
Re: a type (typename) as a parameter of a function
You can't pass a type as an actual argument, you can only pass an object of a given type.
Quote:
I undestand it as the reference to the name of the type is given to the function as a parameter.
No, a reference to an object of that type is given to the function as a parameter.
Re: a type (typename) as a parameter of a function
Thank you for answer, and sorry for asking such a stupid question. Just something wrong is today with my head.
Re: a type (typename) as a parameter of a function
Quote:
Originally Posted by
StudentFS
Thank you for answer, and sorry for asking such a stupid question. Just something wrong is today with my head.
There is no such thing as a stupid question.....there are only stupid answers (and these are usually my part).
Jokes aside....that is why the forum exists....don't hesitate to ask anything just because you might think it would be stupid....
Re: a type (typename) as a parameter of a function