E
E
EugenePavlov2020-03-21 12:05:59
CRM
EugenePavlov, 2020-03-21 12:05:59

What is a void instance?

Hello. I saw this thing:

#ifdef NDEBUG
#define LOGGER() (true) ? void() : Logger()
#else
#define LOGGER() Logger()
#endif


And also this:
void foo(void)
{
    return void(); // ?!?!
}


What is it? Why is this? How it works?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anatoly Kulikov, 2019-08-23
@anatoly_kulikov

Of these two, I only worked with Bitrix, I liked it very much. It works quite fast, there are very useful chips. For example, you can make feedback forms, attach an online chat - very convenient, because the leads will be spinning in one space. Another convenient thing is that there is an internal chat for employees (there is no need to use third-party messengers).
It is convenient to maintain a database of both customers and contractors.
In addition, there are mobile applications.
In my practice, the tasks overlapped completely, so I can’t really talk about the minuses.

V
Victor Bomberow, 2020-03-21
@EugenePavlov

#include <iostream>
using namespace std;

int main() {
  cout << int() << endl;
  cout << double(78) << endl;
  
  cout << bool(-1) << endl;
  
  // void r = void();
  // error: void value not ignored as it ought to be
  
  void();
  void(42);
  return 0;
}

Output:
0
78
1
This is syntactic sugar, which can be understood as a built-in type constructor, but in fact it works like a cast to
(int)0, (double)76, (bool)-1 respectively
and the constructor is not called.
Those. when compiling, instead of void(), (void)0 will occur, the result will be void. The foo function returns void because it is "backwards compatible" with the C language.

V
Vladislav Lyskov, 2020-03-21
@Vlatqa

This is a function that does not return anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question