Skip to content

Usage of "using std::size_t;" in Eigen/Core

Submitted by pat..@..il.com

Assigned to Nobody

Link to original bugzilla bug (#1382)
Version: 3.3 (current stable)

Description

I discovered recently that Eigen has a line

// we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
// ensure QNX/QCC support
using std::size_t;

in its Eigen/Core header. While I do understand the rationale given in the comment, I consider this to be very intrusive and bad practice. A header-only library shouldn't have any using directives in its headers: It will affect everyone's project that will include this header. I actually wondered in my projects multiple times why the compilers didn't complain when I didn't prefix size_t with std::, and I knew that I hadn't used a using directive in my headers - now I know that it was Eigen's header. I would strongly argue to change this.

There's a few other using directives in the header (e.g. I found "using std::ptrdiff_t;"), the same argument would go for these - but size_t is most bothering.

Edited by Eigen Bugzilla