Eventually I need to filter a typelist (brigand::list
- defined in brigand meta-programming library). But to start:
I have a settings class that holds a type list:
template<typename TComponentList>
class Settings {
// this is an integral_constant holding bool
template<typename TList, typename T>
using ContainsFilter = brigand::found<TList, std::is_same<T, brigand::_1>>;
// is the type present in component list?
template<typename T>
using IsComponentFilter = ContainsFilter<TComponentList, T>;
}
The brigand library offers a filter
"function", but to pass my filter there i need to wrap it using brigand::bind
. Here's an example of that:
using ls = brigand::list<TagA, SignatureA, ComponentB>;
// binds the template parameter - passes it to my filter
using wrapped = brigand::bind<TestSettings::IsComponentFilter, brigand::_1>;
// a list holding only ComponentB
using filtered = brigand::filter<ls, wrapped>;
The last step - which i cannot overcome, is to put the filtering inside a class, depending on a template param:
template <class TSettings>
struct FilteringClass
{
// problem line
using wrapped = brigand::bind<TSettings::IsComponentFilter, brigand::_1>;
// template<typename TSignature>
// using SignatureComponents = brigand::filter<TSignature, wrapped>;
};
When compiling the problem line i first get an error that i need to use typename keyword before TSettings
:
to refer to a type member of a template parameter, use 'typename TSettings::
That sounds exactly like what i want!
I guess it is needed to explicitly tell compiler to treat TSettings
as a type? However when i add it, i get this error from inside brigand's
bind function:
error: type/value mismatch at argument 1 in template parameter list for 'template<template<class ...> class<template-parameter-1-1>, class ...> struct brigand::bind'
using wrapped = brigand::bind<TSettings, brigand::_1>;
note: expected a class template, got '(TSettings:: IsComponentFilter < <expression error>)'