Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable? #14

Open
keynan opened this issue Dec 22, 2014 · 6 comments
Open

Portable? #14

keynan opened this issue Dec 22, 2014 · 6 comments

Comments

@keynan
Copy link

keynan commented Dec 22, 2014

I noticed you aren't supporting VC++. Could you elaborate as to the difficulties?

@beark
Copy link
Owner

beark commented Dec 22, 2014

It's been a while since I worked on this, so I'm not sure I remember everything. Also, most of what I do remember may no longer be a problem in VS2015 (or whatever the next VS version will be), I haven't really kept track of it.

As for what the problems were, here's a list of things:

  • Unrestricted unions. sum_type requires this to work with anything beyond primitive types (which includes maybe and either as they are implemented currently).
  • Various TMP-related compiler errors, some/most of which may have been resolved already--I didn't retest for VS2013, since I knew it would still lack other things.
  • constexpr, used heavily throughout. Might be possible to fix by only conditionally using them (#ifdef/macros).
  • noexcept, similar situations as constexpr.

I think the biggest remaining issue (since VS2013 supports variadic templates) is the unrestricted unions, and perhaps even that could be worked around with std::aligned_union.

However, there's still one pretty big problem: I do not have Windows or VS. So until someone sends a pull request, it's unfortunately not likely to happen.

Summary/TLDR: I don't think there's anything left that couldn't be worked around, but I don't have the tools or means to do so.

@keynan
Copy link
Author

keynan commented Dec 23, 2014

VS 2015 preview is out and I think free, being a preview. I'd like to help but I'm not really much a c++ programmer. Even VS 2015 seems to be embarrassingly behind in implementing the c++11 standard, given how much MS claims to use the language.

@zsszatmari
Copy link

Hi! I started working on this, however I wouldn't call myself a template guru, so a little hint would be welcome.

template<
typename...Ts,
typename = typename std::enable_if<All<Eq,Ts...>{}>::type
>
bool operator== (const sum_type<Ts...>& a, const sum_type<Ts...>& b) {
size_t i1 = ::ftl::_dtl::sum_type_accessor::activeIndex(a);
size_t i2 = ::ftl::_dtl::sum_type_accessor::activeIndex(b);

    return i1 == i2 && ::ftl::_dtl::sum_type_accessor::compareAt(i1, a, b);
}

Apparently, VS2013 does not like this: typename = typename std::enable_if<All<Eq,Ts...>{}>::type

error C2783: 'bool ftl::operator ==(const ftl::sum_type<Ts...> &,const ftl::sum_type<Ts...> &)' : could not deduce template argument for ''

Any hint on how to achieve the same functionality in a more VS-friendly manner? Or is it even necessary? it might just fail to compile if you try to compare things which are not meant to be compared, but I might be missing a point here, so better ask.

@beark
Copy link
Owner

beark commented Jan 3, 2015

One possible cause is that one of the Ts bool operator==(const sum_type&, const sum_type&) is being instantiated for does not have operator== defined. But it seems unlikely, at least if you're just compiling the included tests.

Another guess in blind is that it might help to explicitly refer to the value member of All, as in:

template<
        typename...Ts,
        typename = typename std::enable_if<All<Eq,Ts...>::value>::type
>
bool operator== (const sum_type<Ts...>& a, const sum_type<Ts...>& b) {

Is what you posted the complete output? Are there errors before or after?

Also, if you want better code formatting, syntax highlighting etc in posted code, enclose it in three back-ticks followed by the language code, e.g. like this for C++:

```cpp
some code
 ```

@zsszatmari
Copy link

Thanks, ::value did the trick! Sorry for the bad formatting :)

@beark
Copy link
Owner

beark commented Jan 3, 2015

No problem, just happy to see someone contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants