MantisBT - CMake
View Issue Details
0016042CMakeModulespublic2016-03-31 11:282016-06-10 14:21
Daniele E. Domenichelli 
Stephen Kelly 
normalfeaturealways
closedno change required 
CMake 3.5 
 
0016042: WriteCompilerDetectionHeader does not define YARP_DEFAULTED_FUNCTION
write_compiler_detection_header(
  FILE "${CMAKE_CURRENT_BINARY_DIR}/compiler_detection.h"
  PREFIX FOO
  COMPILERS
    GNU
  FEATURES
    cxx_deleted_functions
    cxx_defaulted_functions)


Generates the following defines

* YARP_DELETED_FUNCTION ("= delete" or empty if not supported)


I'd expect to see YARP_DEFAULTED_FUNCTION defined in this way (or something similar):

* YARP_DEFAULTED_FUNCTION ("= default" or "{}" if not supported)


Is there some drawback in doing so?
No tags attached.
Issue History
2016-03-31 11:28Daniele E. DomenichelliNew Issue
2016-03-31 11:36Brad KingNote Added: 0040776
2016-03-31 13:18Stephen KellyNote Added: 0040780
2016-03-31 13:18Stephen KellyStatusnew => resolved
2016-03-31 13:18Stephen KellyResolutionopen => no change required
2016-03-31 13:18Stephen KellyAssigned To => Stephen Kelly
2016-03-31 13:21Stephen KellyNote Added: 0040781
2016-06-10 14:21Kitware RobotNote Added: 0041209
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040776)
Brad King   
2016-03-31 11:36   
Steve, was this just an oversight in the implementation?
(0040780)
Stephen Kelly   
2016-03-31 13:18   
struct A
{
  int i;
  A(int val = 0) : i(val) {}
  A(A const&) {}
};

is not the same as

struct A
{
  int i;
  A(int val = 0) : i(val) {}
  A(A const& other) = default;
};

Please re-open if you can show how the macro would be used in a valid way.
(0040781)
Stephen Kelly   
2016-03-31 13:21   
For completeness,

struct A
{
  int i;
  A(int val = 0) : i(val) {}

private:
  A(A const&) = delete;
  A& operator=(A const&) = delete;
};

and

struct A
{
  int i;
  A(int val = 0) : i(val) {}

private:
  A(A const&);
  A& operator=(A const&);
};

are both sensible (but the compiler can give a better message for the = delete). See Q_DISABLE_COPY. I submitted a Q_DISABLE_COPY-like macro when writing WriteCompilerDetectionHeader, but it was rejected. Brad was doing reviews off-list unfortunately, so I can't link you to it, but here is the relevant part:

On 05/09/2014 08:35 PM, Brad King wrote:
> Later in the Feature/Define table, I see:
>
> > # ``cxx_deleted_functions`` ``@PREFIX@_DISABLE_COPY``
>
> and in the test header I see:
>
> > # define TEST_DISABLE_COPY(X) \
> > private: \
> > X(X const&) TEST_DELETED_FUNCTION; \
> > X& operator=(X const&) TEST_DELETED_FUNCTION;
>
> IMO this is too involved to provide as an API from CMake.
> I never like when macros hide access specifiers either.
> This looks like more of a convenience macro since its
> implementation is not dependent on the compiler. The
> code can easily be spelled out in a project and will
> be clearer. Let's drop this macro.
(0041209)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.