Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Li-Ta Lo
VTK-m
Commits
75b3f816
Commit
75b3f816
authored
Dec 06, 2021
by
Li-Ta Lo
Browse files
clarify on name lookup for overloaded virtural function
parent
ef990668
Pipeline
#258981
waiting for manual action with stages
in 33 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
vtkm/filter/FieldTransform/GenerateIds.h
View file @
75b3f816
...
...
@@ -84,6 +84,7 @@ public:
bool
GetUseFloat
()
const
{
return
this
->
UseFloat
;
}
void
SetUseFloat
(
bool
flag
)
{
this
->
UseFloat
=
flag
;
}
using
vtkm
::
filter
::
NewFilter
::
Execute
;
// bring overloads of Execute into name lookup
vtkm
::
cont
::
DataSet
Execute
(
const
vtkm
::
cont
::
DataSet
&
input
)
override
;
};
...
...
vtkm/filter/NewFilter.h
View file @
75b3f816
...
...
@@ -230,10 +230,27 @@ namespace filter
/// Implementations of Filter subclass can also override
/// `DetermineNumberOfThreads()` to provide implementation specific heuristic.
///
/// \subsection FilterNameLookup Using Declaration
/// In some cases, the compiler is unable to find the overloads of `Execute` and tries to call
/// `Execute(DataSet&)` while passing a `PartitionedDataSet` or vice versa. The solution
/// is to use a using-declaration in the subclass definition. For example:
/// \subsection FilterNameLookup Overriding Overloaded Functions
/// The rule of name lookup for inherited, overloaded functions dictates us to either override
/// none of the overloads or all of them. Since we have two overloads of `Execute`, implementation
/// of a NewFilter subclass needs to override both of them. In most uses cases, we intend to only
/// override the `Execute(DataSet&)` overload, such as
///
/// \code{cpp}
/// class FooFilter : public NewFilter
/// {
/// ...
/// vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input) override;
/// ...
/// }
/// \endcode
///
/// However, the compiler will stop the name lookup process once it sees the
/// `FooFilter::Execute(DataSet)`. When a user calls `FooFilter::Execute(PartitionedDataSet&)`,
/// the compiler will not find the overload from the base class `NewFilter`, resulting in failed
/// overload resolution. The solution to such a problem is to use a using-declaration in the
/// subclass definition to bring the `NewFilter::Execute(PartitionedDataSet&)` into scope for
/// name lookup. For example:
///
/// \code{cpp}
/// class FooFilter : public NewFilter
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment