I would rewrite it to something like this:

import std.stdio;
import std.functional;

template BTree(ValueT, KeyT = ValueT,alias KeyF = unaryFun!"cast(const)a")
{
    class BTree
    {
        auto getKey(ValueT val) {
            return KeyF(val);
        }
    }
}

void main()
{
    auto btree1 = new BTree!(char)();  // Removing this line eliminates the error.
    auto btree2 = new BTree!(int)();
}

On Sun, May 27, 2018 at 9:03 AM, Vijay Nayar via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On Saturday, 26 May 2018 at 11:56:30 UTC, Vijay Nayar wrote:
The error is:
```
onlineapp.d(8): Error: function literal `__lambda6(char a)` is not callable using argument types `(int)`
onlineapp.d(8):        cannot pass argument `val` of type `int` to parameter `char a`
onlineapp.d(15): Error: template instance `onlineapp.BTree!(int, int, function (char a) => a)` error instantiating
```

Just to clarify.  In the example above, if I create a 'BTree!int' by itself, it's fine.  If I create a 'BTree!char' by itself, it's fine also.  But if I create both, even if they are created in different modules, the compiler seems to mix up the types of the function template-parameter, and tries to fit a 'char' to the 'int' function or an 'int' to the 'char' function, depending on which was declared first.