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

Switch to c++17 and remove Boost #106

Closed
breznak opened this issue Nov 13, 2018 · 6 comments
Closed

Switch to c++17 and remove Boost #106

breznak opened this issue Nov 13, 2018 · 6 comments

Comments

@breznak
Copy link
Member

breznak commented Nov 13, 2018

We need to get rid of SWIG before this step.

After #55
After #81

@breznak breznak added this to the pybind milestone Nov 13, 2018
@dkeeney
Copy link

dkeeney commented Nov 15, 2018

@breznak here is something for you to look into...
There are two Functors at the end of nupic/math/Utils.hpp
These don't compile on C++17 because std::unary_function<Pair...> is no longer supported.

Here is some code that seems to work under MSVC, C++17 but when I tried it on Ubuntu C++11 it would not compile. Did not investigate further. If you are looking for something to do can you look into this for me? Don't need it until we switch to C++17.

  /**
   * This is a 'C++ function object' or Functor.  An object that can be passed
   * as if it were a C function. It is created by having a class containing an
   * overload of the () operator.
   * This replaces the std::unary_function<> which is not in C++17
   *
   * Function object that takes a single argument, a pair (or at least
   * a class with the same interface as pair), and returns the pair's
   * first argument.
   */
  template <typename Pair>
  struct select1st {
    inline const auto &operator()(Pair &x) const {
      return x.first;
    }
  };

  /**
   * This is a 'C++ function object' or Functor.  An object that can be passed
   * as if it were a C function. It is created by having a class containing an
   * overload of the () operator.
   * This replaces the std::unary_function<> which is not in C++17
   *
   * It is a Function object that takes a single argument,
   * a pair (or at least a class with the same interface as pair), and returns the
   * pair's second element.
   */
  template <class Pair> struct select2nd {
    inline const auto &operator()(const Pair &x) const {
      return x.second;
    };
  };

@breznak
Copy link
Member Author

breznak commented Nov 15, 2018

I'll try

but when I tried it on Ubuntu C++11 it would not compile.

So dows it fail on c++17, or 11?
Functors normally work ok in gcc/clang, must be ill-formed or sth

@dkeeney
Copy link

dkeeney commented Nov 15, 2018

It was failing on 11.
Let me stick it back in and try again.

@dkeeney
Copy link

dkeeney commented Nov 15, 2018

Here is the error:

/home/dave/cpp/src/nupic/math/Utils.hpp:366:44: error: ‘operator()’ function uses ‘auto’ type specifier without trailing return type
     inline const auto &operator()(Pair &x) const {
                                            ^~~~~
/home/dave/cpp/src/nupic/math/Utils.hpp:366:44: note: deduced return type only available with -std=c++14 or -std=gnu++14

If I had read the entire error message it told me why.
So, I guess I will put some conditional compile around it and use the new one for C++14 or greater.

@breznak breznak mentioned this issue Nov 25, 2018
5 tasks
@breznak breznak modified the milestones: pybind, Dependencies_redux Dec 19, 2018
@breznak
Copy link
Member Author

breznak commented Dec 19, 2018

With #169 we'll have most of boost includes removed,
only remaining are

  • math/ArrayAlgo.hpp
  • math/Math.hpp

and I'm working on those.

@dkeeney can we revisit switch to c++17 #55 and then proceed with this one?

@dkeeney
Copy link

dkeeney commented Dec 19, 2018

Hmmm, I thought I already got rid of those....Oh, The concept_check. We can probably just delete that but perhaps someone thinks those are useful.

@dkeeney dkeeney closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants