0

Special member functions are "functions which the compiler will automatically generate if they are used, but not declared explicitly by the programmer".

http://en.wikipedia.org/wiki/Special_member_functions

Details are in §12 of the C++11 Standard:

The default constructor (12.1), copy constructor and copy assignment operator (12.8), move constructor and move assignment operator (12.8), and destructor (12.4) are special member functions. [Note: The implementation will implicitly declare these member functions for some class types when the program does not explicitly declare them. The implementation will implicitly define them if they are odr-used (3.2). See 12.1,12.4 and 12.8. —end note]

What known methods can identify all generated special member functions upon compilation?

My preferred compilers are gcc and clang.

2
  • Why do you need this? Commented Sep 13, 2014 at 8:53
  • I would like a systematic way of revealing use of these defaults, especially default copy constructors. Commented Sep 13, 2014 at 21:34

1 Answer 1

1

In c++11, header <type_traits> defines a set of following functions:

is_constructible is_default_contructible is_copy_contructible is_move_contructible is_assignable is_copy_assignable is_move_assignable is_destructible 

You can use them to test for existence of implicitly generated methods at compile time, eg.:

std::is_constructible<ClassName>::value 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.