These are chat archives for boostorg/hana

27th
Nov 2015
Maik Klein
@MaikKlein
Nov 27 2015 02:44
hm, how do I get hana tuples inside a struct/class?
template<template<class...> class Container, class... Components>
struct component_group{
using component_container_tuple = std::tuple<Container<Components>...>;
component_container_tuple component_container;

//hana
static auto comp_tup = hana::tuple_t<Components...>;
static auto comp_tup_container = hana::transform(comp_tup, [](auto t){
return hana::type_c<Container<decltype(t)>>;
});
typename decltype(comp_tup_container)::type component_container_hana;
....
};
How would I translate the first two lines to hana?
do I really need to initialize them outside the struct/class?
Maik Klein
@MaikKlein
Nov 27 2015 03:04
I would like to make it a constexpr but I am not allowed to use a lambda in a constexpr
Jason Rice
@ricejasonf
Nov 27 2015 04:03
I'm also interested in knowing the proper way to do this. I currently use default construction.
although maybe my scenario is slightly different
Jason Rice
@ricejasonf
Nov 27 2015 04:41
wouldn't this work? constexpr static auto comp_tup_container = hana::tuple_t<Container<Components>...>;
Maik Klein
@MaikKlein
Nov 27 2015 09:25
yeah probably but I also want to use the comp_tup
Maik Klein
@MaikKlein
Nov 27 2015 12:03
@ldionne btw the images for the benchmark at https://boostorg.github.io/hana/ are not visible.
Louis Dionne
@ldionne
Nov 27 2015 12:45
@MaikKlein This is a Safari issue. Did you update Safari recently?
@MaikKlein Try with chrome and let me know if it works for you. On my side it works with Chrome but not Safari
Louis Dionne
@ldionne
Nov 27 2015 13:51
Regarding you above question, I would simply write
template<template<class...> class Container, class... Components>
struct component_group{
using component_container_tuple = hana::tuple<Container<Components>...>;
component_container_tuple component_container;
};
No wizardry here, lol.
Maik Klein
@MaikKlein
Nov 27 2015 14:08
@ldionne But what if I would need a more complex transformation and I would need to use hana::filter/transform?
@ldionne "Https everywhere" just blocked the charts for me.
Louis Dionne
@ldionne
Nov 27 2015 14:09
What wait?
What OS/Browser are you using?
Maik Klein
@MaikKlein
Nov 27 2015 14:10
chrome linux
Louis Dionne
@ldionne
Nov 27 2015 14:11
So you say you’re not seeing any charts right now?
Maik Klein
@MaikKlein
Nov 27 2015 14:13
I have added an exception, I can see the charts now.
using "chromium" not chrome sry
From OS X, I can see them with Firefox, Chrome and Safari.
Maik Klein
@MaikKlein
Nov 27 2015 14:18
works now if I remove the rule, let me clear the cache..
yeah seems to work now in chrome and firefox. Strange, have you actually changed anything?
ah
(index):1 Mixed Content: The page at 'https://boostorg.github.io/hana/#tutorial-performance-compile' was loaded over HTTPS, but requested an insecure script 'http://cdn.mathjax.org/mathjax/latest/MathJax.js'. This request has been blocked; the content must be served over HTTPS.
Louis Dionne
@ldionne
Nov 27 2015 14:27
Try again. Do you still get this?
I’ve no idea why it started doing it yesterday, but it seemed to work before.
Maik Klein
@MaikKlein
Nov 27 2015 14:27
It's gone now
Louis Dionne
@ldionne
Nov 27 2015 14:28
Ok. Basically, I need to load external scripts using the right protocol (http if you connect to the documentation with http, and https otherwise).
Or so it seems.
Maik Klein
@MaikKlein
Nov 27 2015 14:32
Can I not use lambas with constexpr in structs/classes? I also tried to use "BOOST_HANA_CONSTEXPR_LAMBDA" but it didn't seem to have an effect.
Louis Dionne
@ldionne
Nov 27 2015 14:33
BOOST_HANA_CONSTEXPR_LAMBDA is defined as nothing, because constexpr lambdas are not supported. For the time being, you can’t use lambdas inside constexpr, but this is about to change in C++17.
Maik Klein
@MaikKlein
Nov 27 2015 14:34
Does clang support this in c++1z?
Louis Dionne
@ldionne
Nov 27 2015 14:38
I don’t think Clang supports this in C++1z. This hack does not work because the operator() of the lambda is still not constexpr.
template<template<class...> class Container, class... Components>
struct component_group{
static auto make_component_tuple() {
auto components = hana::tuple_t<Components...>;
auto transformed_components = hana::transform(components, [](auto t){
using T = typename decltype(t)::type;
return hana::type_c<Container<T>>;
});
// do whatever you want here; can use filter and anything else
// now, let's say you end up with some tuple containing hana::types.
// What you want is probably to instantiate a hana::tuple that
// contains objects of those types. You can do the following:
return hana::unpack(transformed_components, hana::template_<hana::tuple>);

// ^^ This returns a hana::type<hana::tuple<the-types-that-were-inside-the-tuple>>
}

using MyTuple = typename decltype(make_component_tuple())::type;
MyTuple component_container_hana;
};
constexpr really does not change anything, since what you’re interested in is just the resulting type.
Also, FYI, the above transformation that creates a Container<T> for each T in the components is equivalent to hana::transform(components, hana::template_<Container>)
Maik Klein
@MaikKlein
Nov 27 2015 14:46
ah okay
thanks
Louis Dionne
@ldionne
Nov 27 2015 15:05
@MaikKlein Sorry to be annoying, but can you please check the documentation on your side on both https://boostorg.github.io/hana/#tutorial-performance-compile and http://boostorg.github.io/hana/#tutorial-performance-compile ?
I just read that using protocol-relative URLs was an anti-pattern and that https should always be used. It works on my side with all browsers, but I’d like to make sure.
Damn web programming, I hate this.
Maik Klein
@MaikKlein
Nov 27 2015 15:30
the http one will just redirect to https
and it works for both
Louis Dionne
@ldionne
Nov 27 2015 15:31
Cool, great. Thanks
Maik Klein
@MaikKlein
Nov 27 2015 15:31
no problem
btw do you think "modules" will make it into C++17?
Louis Dionne
@ldionne
Nov 27 2015 15:35
I have absolutely no idea. I have not been following this topic closely, so I couldn’t tell.
Jason Rice
@ricejasonf
Nov 27 2015 19:54
I hate osx. I'm using a symlink in /usr/local/include and cpp -v shows it as the first in the list, but it is still not finding #include<boost/hana.hpp>
Jason Rice
@ricejasonf
Nov 27 2015 20:44
Are you sure I can't use hana::common in lieu of std::common_type? The libc++ version on my recently updated mac still has that bug.
that is std::common_type<void, void> does not compile
The suggested change to std::common_type_t was working for me on my linux box because I was using libstd++
Louis Dionne
@ldionne
Nov 27 2015 21:51
@ricejasonf Well, you can use it if you want, but it won’t do what you’re looking for. hana::common<hana::tuple<X, Y>, hana::tuple<Y, Z>> is hana::tuple_tag instead of an error. Clearly not what you’re looking for.
It’s fairly easy to implement a sfinae-friendly std::common_type if you don’t need it to allow being specialized for user-defined types.
I would just write my own if I were you, perhaps?
Jason Rice
@ricejasonf
Nov 27 2015 22:09
ahh I see. I'll look into that or maybe dip into boost/type_traits idk
or abandon mac altogether :P
one problem after another Undefined symbols for architecture x86_64