Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting Concept From Module

I can't find nothing about C++ modules and concepts interaction. Is the syntax of exporting concept from module correct?

export module Module;

template <typename S>
export concept sequence = true;
like image 493
Serge Kork Avatar asked Oct 28 '25 21:10

Serge Kork


1 Answers

export exports declarations. A concept definition is a declaration and can therefore be exported. It works just like exporting any other declaration, as far as the results of such an export work.

As for the specific grammar, export is applied to the "declaration" grammar rule. And "template-declaration" is a kind of "declaration". A "template-declaration" includes the template header, but the grammatical definition for "template-declaration" says that it's a "template-head" followed by a "declaration" or a "template-head" followed by a "concept-definition".

So just from the grammar, if you want to export a concept definition, you have to do it before the template header, since concept-definition doesn't include export as valid grammar.

However, if you're wondering about exporting regular templates, one might think that, from this grammar, export could come before the "template-head" or after. However, the standard specifically says this:

[A template-declaration's] declaration shall not be an export-declaration.

From this, we conclude that all templates put export before the template-head.

like image 116
Nicol Bolas Avatar answered Oct 30 '25 12:10

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!