Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 15:06

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 24 07:47

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 23 02:04
    pthom commented #432
  • Jan 18 12:46

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 16 22:27
    ricejasonf commented #434
  • Jan 05 06:22
    ricejasonf commented #330
  • Jan 03 11:40

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 02 00:33
    ricejasonf closed #434
  • Jan 02 00:33
    ricejasonf commented #434
  • Jan 02 00:04
    ricejasonf opened #434
  • Dec 27 2018 13:11

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Dec 22 2018 11:56
    pthom commented #432
  • Dec 22 2018 11:55
    pthom commented #432
  • Dec 21 2018 15:48
    pthom synchronize #432
  • Dec 21 2018 09:19
    sdebionne opened #433
  • Dec 21 2018 00:08
    ricejasonf commented #432
  • Dec 21 2018 00:03
    ricejasonf commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:13
    ricejasonf commented #432
Andreas Borgen Longva
@Andlon
I.e. can I for example just bundle the header files with the project?
Or even better, since Hana is a CMake project, can I simply include it as a cmake subdirectory?
Jason Rice
@ricejasonf
yeah it is standalone, header only. you can use cmake or just copy the contents of the 'include' directory.
Andreas Borgen Longva
@Andlon
All right, thanks for the clarification! That sounds really great, looking forward to try it out!
Van Nevel Mathieu
@Celes-Eternal
Hi guys, I have a question which is not directly for boost hana. I mean, I'm making some research about C++ library documentation, with metaprogramming, concepts and all this kind of stuff. And I didn't find any real answer, except using macros and doxygen. And it looks like it's what you're using. So I was wondering, is that a convenient approach? Or if you had to start another project you will use something else? Thanks :)
Jason Rice
@ricejasonf
"standardese" is a wip but worth looking at
Van Nevel Mathieu
@Celes-Eternal
@ricejasonf I searched this one all the afternoon! Thanks ^^
Still if someone have something to say, it's not like I have made up my mind
Adam Getchell
@acgetchell
I’d love to use standardese, but it doesn’t support LaTeX.
Andreas Borgen Longva
@Andlon
I'm a little bit confused about the issue of MSVC support for Hana. Can I not use it at all, or is it rather that some features will work and some won't?
I'd like us to use Hana for a project, and though I'm on Linux, my colleagues use Windows and MSVC
I think our only intended usage is to do something like a for-each loop over a compile-time defined set of types
Jason Rice
@ricejasonf
I've not tried it, but AFAIU all of the features work. I think they have their own fork or you can try the develop branch.
Andreas Borgen Longva
@Andlon
oh, interesting! Thanks, we will probably try it out and see how it works for us. Though we're still some time away until we actually get to the point where we will need Hana
Darth Rubik
@DarthRubik
Is there a way to automatically generate the == and != operators for a model of the comparable concept?
Jason Rice
@ricejasonf
I don't think so
Jason Rice
@ricejasonf
It works the other way around though, but you still have to define both == and !=... they should fix that or something
jw0k
@jw0k
Hi guys, I have a question about BOOST_HANA_ADAPT_STRUCT and inheritance. Is it possible to use this macro on a struct that inherits some base struct and then iterate over all elements of the derived struct (including inherited ones)?
Jason Rice
@ricejasonf
Hey, unfortunately, the macro does not support that. There is an existing feature request though: boostorg/hana#339
jw0k
@jw0k
@ricejasonf Thank you for the answer. Is someone working on it? If not, is it OK if I started working on it? Are pull requests welcome?
Jason Rice
@ricejasonf
Yeah probably. I don't think he would have made an issue if it wasn't an acceptable idea.
Jason Rice
@ricejasonf
@jw0k If you end up doing that, don't hesitate to submit the PR at an early stage so you can get feedback and what not.
jw0k
@jw0k
OK, sure.
jw0k
@jw0k

All right, I made a quick and dirty proof of concept that seems to work. You would use it like this:

struct Animal
{
    BOOST_HANA_DEFINE_STRUCT(Animal,
        (std::string, name)
    );
};

struct Dog : Animal
{
    BOOST_HANA_DEFINE_INHERITED_STRUCT(Dog, Animal,
        (double, tailLength)
    );
};

The problem is it only supports single inheritance. In case of multiple inheritance I'm not sure how to deal with 2 sets of variadic args in a macro at the moment

Jason Rice
@ricejasonf
I think they had the same problem here: boostorg/hana#409
Maybe there could be a separate macro that merely defined the base classes of a class for introspection and the existing macro could check that
It would probably have to introduce a new concept like hana::StructInherited or something named better :P
Lukas Barth
@tinloaf
Hi! I'm trying to understand how boost::hana::for_each works. However, this seems beyond me. In https://github.com/boostorg/hana/blob/master/include/boost/hana/fwd/for_each.hpp , the functor f is never evaluated. Also, there is no definition for operator(). for_each_impl is declared and defined, but never used anywhere. How does this arcane magic work?
D'Oh. There's a second file I missed.
Jason Rice
@ricejasonf
ha ha yeah the fwd is for "forward declaration"
Shreyans
@shreyans800755
Hi guys
I want to check if a particular a particular class has a specific member variabal. I got one simple solution in 2nd answer of the question https://stackoverflow.com/questions/1005476/how-to-detect-whether-there-is-a-specific-member-variable-in-class.
But, I want to do this at multiple places in my codebase. And this leads to adding 2 such templates every time. I tried to make a generic function to do this , but I couldn't understand how can I pass the variable name as a param which may or may not be present in that class. The closest I came to this was using a macro which will generate both the templates every time.
I was wondering if anyone of you has come across similar scenario and found any non-macro solution.
Thanks in advance
Shreyans
@shreyans800755
Here's the complete code for the above:
#include <bits/stdc++.h>

using namespace std;

template <typename T, typename = int>
struct HasX : false_type {};

template <typename T>
struct HasX<T, decltype(T::x, 0)> : true_type {};

struct A{int x;};
struct B{int y;};

int main()
{
    cout << HasX<A>::value; // Prints 1
    cout << HasX<B>::value; // Prints 0
}
Andreas Pokorny
@APokorny
I would rather raise the question whether HasX is a useful utility at all
so If you have code that uses specific properties of a type .. I would expect that X isnt the only thing that you might want to check for
so in the end you might come up with a whol bunch of checks .. and then you arrive at void_t
Shreyans
@shreyans800755

@APokorny The scenario is that, I've got 2 different types of ids in a bunch of classes. So, based on which id does a class have, I have to put the next logic.
Something like:
if(hasId1)...
else if(hasId2)...

I know that its not the best design in the first place, but changing that would be massive change in whole codebase, which I can't afford at the moment. But with the code I gave, I have to write 2 templates for all different classes, which is cumbersome and not good in terms of scalability.

Andreas Pokorny
@APokorny
so there are many different 'x' that you want to capture?
or there are many Ts?
or there are many places in which you need to test for HasId1 vs HasId2?
Shreyans
@shreyans800755
Actually both. In some cases, I have multiple Ts, and in others I have multiple member variables that I want to check for.
Andreas Pokorny
@APokorny
hm then maybe you dont need a trait
Shreyans
@shreyans800755
So, I would like to have a generic function like HasMember<A, x>() or HasMember(A, x). But I don't know how can I pass x w/o declaring it.
Andreas Pokorny
@APokorny
just a add a template<typename ...Ts> using void_t = void; and use it to form a decltype that yields a substitution error if any of the requested members are not available
so you end up ith tempalte<typename A, typename B, typename D = void_t<decltype(A::x, B::x, B::y)>
or something along the lines of that..
Shreyans
@shreyans800755
But that's still not generic enough. I'll have to change the templates if I change the variable name or add a new class. I want to have a generic function if possible
Andreas Pokorny
@APokorny
what I propose would not require changes if you add new structs
hm and also the checks for members would be excatly at the places where those members are accessed
Shreyans
@shreyans800755

I want to do someting like this:
if(Has<A, x>()::value)
...

And
if(Has<B, y>()::value)
...

I'm not sure how can I achieve with tempalte<typename A, typename B, typename D = void_t<decltype(A::x, B::x, B::y)> or something like that.
My main problem is the member variable. I'm not sure how I can pass that

Jason Rice
@ricejasonf
The name can only be passed via preprocessor macro. Is this close to what you are trying to do? https://godbolt.org/z/4WsTTN