public imports and template functions
Jonathan M Davis
jmdavisProg at gmx.com
Wed Nov 24 00:13:09 PST 2010
Am I correct in my understanding that if you wish a template function which is
imported from another module to compile correctly without requiring other
imports in the module that your using the function in that the module with the
template function needs to publically import all of the functions and types that
it needs?
So, if you had
----------------------
module a;
import std.algorithm;
void func(R)(R range)
{
sort(range);
}
--------------------------
module b;
import module a;
void foobar(int[] vals)
{
sort(vals);
}
----------------------------------
then you'd have to import std.algorithm (or std.algorithm.sort) in module b, and
if you didn't want to require that, you'd do
public import std.algorithm : sort;
in module a. Is that correct? Or is my understanding off?
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list