0

Looking at the mettle test framework they have code like this:

#include <mettle.hpp>
using namespace mettle;

suite<> basic("a basic suite", [](auto &_) {

  _.test("a test", []() {
    expect(true, equal_to(true));
  });

  for(int i = 0; i < 4; i++) {
    _.test("test number " + std::to_string(i), [i]() {
      expect(i % 2, less(2));
    });
  }

  subsuite<>(_, "a subsuite", [](auto &_) {
    _.test("a sub-test", []() {
      expect(true, equal_to(true));
    });
  });

});

Is there something special going on with the use of underscore or is it a valid variable name?

Joshua
  • 40,822
  • 8
  • 72
  • 132
JeffV
  • 52,985
  • 32
  • 103
  • 124

1 Answers1

1

Is there something special going on with the use of underscore

Underscore is a valid character to use in an identifier. Some uses of underscore in an identifier are reserved for the implementation: What are the rules about using an underscore in a C++ identifier? But none of those apply to a single underscore in block scope.

is it a valid variable name?

Here, yes. It wouldn't be in global namespace.

Community
  • 1
  • 1
eerorika
  • 232,697
  • 12
  • 197
  • 326