at_c and lists with reference types
ericniebler opened this issue · 3 comments
ericniebler commented
namespace brigand
{
namespace detail
{
template<class T> struct element_at;
template<class... Ts>
struct element_at<list<Ts...>>
{
template<class T> T static at(Ts..., T*, ...);
};
template<std::size_t N, typename Seq> struct at_impl;
template<std::size_t N, template<typename...> class L, class... Ts>
struct at_impl<N,L<Ts...>>
{
using type = decltype(element_at<brigand::filled_list<void const *, N>>::at(static_cast<Ts*>(nullptr)...));
};
}
template <class L, std::size_t Index>
using at_c = typename detail::at_impl<Index, L>::type;
There's no way that this works if the list has a reference type in it since it forms a pointer to a reference, which is ill-formed.
jfalcou commented
This looks like case for our good old type_<> bundler, @edouarda what do you think ?
edouarda commented
I think I wanted to type "1st" but you stole me that pleasure. 😐
edouarda commented
Apart from that, yes we should use the for_each
trick of type_<>
https://github.com/edouarda/brigand/blob/master/brigand/types/type.hpp