Pcl: Replace boost::mt19937 with std::mt19937

Created on 23 Jan 2019  路  2Comments  路  Source: PointCloudLibrary/pcl

boost::mt19937 is sometimes used in header files as member. How do we migrate to std::mt19937 there? A typedef doesn't work, because e.g. boost::variate_generator doesn't exists in final C++11 spec (was only in tr1).

So there are two options:

  • Hardcut for this members. Everyone, who inherits from this classes, needs ti adjust their code from PCL 1.9.1 to 1.10.0 in case they are using this member.
  • typedef + #ifdef (don't know if we want many new #ifdefs)
  • typedef and increase/define minimum required boost version, in case Boost implemented C++11 spec
stale

Most helpful comment

According to my current understanding, when transitioning from Boost to standard library classes we should generally follow these rules:

Where | What to do
------ | --------
only in implementation | swap
private member | swap
protected member | maybe swap
public or API | introduce typedef

Speaking about random generators in particular, I found occurrences (in headers) in the following modules:

  1. Common: both private and public;
  2. Surface: only private :heavy_check_mark:
  3. Outofcore: in some places private, in some places protected
  4. SAC: protected members
  5. Filters: only private :heavy_check_mark:

Comments:

1] Arguably it's public in NormalGenerator by mistake, so we should actually make it private.
3] Swap. Outofcore is not a very popular module anyway, extremely unlikely that someone is maintaining his own deriving classes on top of it.
4] Random number generation is encapsulated in rnd() method, deriving classes very unlikely to deal with the generator/engine objects directly. In such a rare case users may add #if branches.

In summary, I think it's safe to swap all occasions of Boost random generators to std.

All 2 comments

According to my current understanding, when transitioning from Boost to standard library classes we should generally follow these rules:

Where | What to do
------ | --------
only in implementation | swap
private member | swap
protected member | maybe swap
public or API | introduce typedef

Speaking about random generators in particular, I found occurrences (in headers) in the following modules:

  1. Common: both private and public;
  2. Surface: only private :heavy_check_mark:
  3. Outofcore: in some places private, in some places protected
  4. SAC: protected members
  5. Filters: only private :heavy_check_mark:

Comments:

1] Arguably it's public in NormalGenerator by mistake, so we should actually make it private.
3] Swap. Outofcore is not a very popular module anyway, extremely unlikely that someone is maintaining his own deriving classes on top of it.
4] Random number generation is encapsulated in rnd() method, deriving classes very unlikely to deal with the generator/engine objects directly. In such a rare case users may add #if branches.

In summary, I think it's safe to swap all occasions of Boost random generators to std.

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.

Was this page helpful?
0 / 5 - 0 ratings