Code completion in C++ templates

Dear community,

I am curious if CLion plans to provide code-completing within class (or function) templates.  I have tried the following snippet:

#include <iostream>
#include <concepts>

struct MsgOne {
int first{1};
};
struct MsgTwo {
int first{10};
double second{100.5};
};

struct DispatcherOne {
void handleMsg(MsgOne& msg) { std::cout << "One: " << msg.first << '\n'; }
};
struct DispatcherTwo {
void handle(MsgTwo msg) { std::cout << "Two: " << msg.first << " " << msg.second << '\n'; }
};

template<typename T>
concept Traits = requires(typename T::DispatcherT a, typename T::MsgT& b)
{
{ a.handleMsg(b) } -> std::same_as<void>;
};

struct TraitsOne {
using DispatcherT = DispatcherOne;
using MsgT = MsgOne;
};

struct TraitsTwo {
using DispatcherT = DispatcherTwo;
using MsgT = MsgTwo;
};

template <Traits T>
struct Driver {
using DispatcherT = typename T::DispatcherT;
using MsgT = typename T::MsgT;
void handleMsg(MsgT &msg) {
dispatcher.handleMsg(msg);
//dispatcher. <- i want code completion here
}
DispatcherT dispatcher;
};

int main() {
Driver<TraitsOne> listener{};
MsgOne msg{};
listener.handleMsg(msg);
}

Hoping that, being constrained by a concept, the instance of DispatcherT in Driver::handleMsg will know to offer me a `handleMsg` method after i type in the dot.

I am aware that Visual Studio does have Template Intellisense feature since 2018.  Is there anything that CLion can do for me?https://godbolt.org/z/GP4v56Er6

Thanks

Vlad

Please sign in to leave a comment.