Can a concept evaluation depend on where it is evaluated?












15














[temp.concept]/5 says:




A concept is not instantiated ([temp.spec]).
[ Note: An id-expression that denotes a concept specialization is evaluated as an expression ([expr.prim.id]). [...]]




Does it mean that this rule bellow ([temp.point]/8) does not apply?




If two different points of instantiation give a template specialization different meanings according to the one-definition rule, the program is ill-formed, no diagnostic required.






For example if this rule does not apply, this code bellow is well formed:



template<class T>
concept Complete = sizeof(T)==sizeof(T);

struct A;

constexpr inline bool b1 = Complete<A>; //Complete<A>==false;

struct A{};

constexpr inline bool b2 = Complete<A>; //Complete<A>==true;


This question is followed by this one










share|improve this question
























  • @bolov Or template<class A> :-P
    – Zereges
    Nov 12 '18 at 10:59








  • 1




    Are you sure the concept definition is well-formed when applied for b1?
    – rubenvb
    Nov 12 '18 at 11:03










  • That concept is ill-formed upon definition IIUC.
    – StoryTeller
    Nov 12 '18 at 11:05












  • @Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
    – StoryTeller
    Nov 12 '18 at 12:59












  • @Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
    – StoryTeller
    Nov 12 '18 at 13:01


















15














[temp.concept]/5 says:




A concept is not instantiated ([temp.spec]).
[ Note: An id-expression that denotes a concept specialization is evaluated as an expression ([expr.prim.id]). [...]]




Does it mean that this rule bellow ([temp.point]/8) does not apply?




If two different points of instantiation give a template specialization different meanings according to the one-definition rule, the program is ill-formed, no diagnostic required.






For example if this rule does not apply, this code bellow is well formed:



template<class T>
concept Complete = sizeof(T)==sizeof(T);

struct A;

constexpr inline bool b1 = Complete<A>; //Complete<A>==false;

struct A{};

constexpr inline bool b2 = Complete<A>; //Complete<A>==true;


This question is followed by this one










share|improve this question
























  • @bolov Or template<class A> :-P
    – Zereges
    Nov 12 '18 at 10:59








  • 1




    Are you sure the concept definition is well-formed when applied for b1?
    – rubenvb
    Nov 12 '18 at 11:03










  • That concept is ill-formed upon definition IIUC.
    – StoryTeller
    Nov 12 '18 at 11:05












  • @Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
    – StoryTeller
    Nov 12 '18 at 12:59












  • @Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
    – StoryTeller
    Nov 12 '18 at 13:01
















15












15








15


3





[temp.concept]/5 says:




A concept is not instantiated ([temp.spec]).
[ Note: An id-expression that denotes a concept specialization is evaluated as an expression ([expr.prim.id]). [...]]




Does it mean that this rule bellow ([temp.point]/8) does not apply?




If two different points of instantiation give a template specialization different meanings according to the one-definition rule, the program is ill-formed, no diagnostic required.






For example if this rule does not apply, this code bellow is well formed:



template<class T>
concept Complete = sizeof(T)==sizeof(T);

struct A;

constexpr inline bool b1 = Complete<A>; //Complete<A>==false;

struct A{};

constexpr inline bool b2 = Complete<A>; //Complete<A>==true;


This question is followed by this one










share|improve this question















[temp.concept]/5 says:




A concept is not instantiated ([temp.spec]).
[ Note: An id-expression that denotes a concept specialization is evaluated as an expression ([expr.prim.id]). [...]]




Does it mean that this rule bellow ([temp.point]/8) does not apply?




If two different points of instantiation give a template specialization different meanings according to the one-definition rule, the program is ill-formed, no diagnostic required.






For example if this rule does not apply, this code bellow is well formed:



template<class T>
concept Complete = sizeof(T)==sizeof(T);

struct A;

constexpr inline bool b1 = Complete<A>; //Complete<A>==false;

struct A{};

constexpr inline bool b2 = Complete<A>; //Complete<A>==true;


This question is followed by this one







c++ language-lawyer c++-concepts c++20






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 13:35







Oliv

















asked Nov 12 '18 at 10:21









OlivOliv

8,4291956




8,4291956












  • @bolov Or template<class A> :-P
    – Zereges
    Nov 12 '18 at 10:59








  • 1




    Are you sure the concept definition is well-formed when applied for b1?
    – rubenvb
    Nov 12 '18 at 11:03










  • That concept is ill-formed upon definition IIUC.
    – StoryTeller
    Nov 12 '18 at 11:05












  • @Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
    – StoryTeller
    Nov 12 '18 at 12:59












  • @Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
    – StoryTeller
    Nov 12 '18 at 13:01




















  • @bolov Or template<class A> :-P
    – Zereges
    Nov 12 '18 at 10:59








  • 1




    Are you sure the concept definition is well-formed when applied for b1?
    – rubenvb
    Nov 12 '18 at 11:03










  • That concept is ill-formed upon definition IIUC.
    – StoryTeller
    Nov 12 '18 at 11:05












  • @Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
    – StoryTeller
    Nov 12 '18 at 12:59












  • @Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
    – StoryTeller
    Nov 12 '18 at 13:01


















@bolov Or template<class A> :-P
– Zereges
Nov 12 '18 at 10:59






@bolov Or template<class A> :-P
– Zereges
Nov 12 '18 at 10:59






1




1




Are you sure the concept definition is well-formed when applied for b1?
– rubenvb
Nov 12 '18 at 11:03




Are you sure the concept definition is well-formed when applied for b1?
– rubenvb
Nov 12 '18 at 11:03












That concept is ill-formed upon definition IIUC.
– StoryTeller
Nov 12 '18 at 11:05






That concept is ill-formed upon definition IIUC.
– StoryTeller
Nov 12 '18 at 11:05














@Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
– StoryTeller
Nov 12 '18 at 12:59






@Oliv - The paragraph I linked says nothing about instantiation, it's about template definition and name lookup. I'd be shocked if one can conjure non-dependent identifiers willy-nilly in a concept.
– StoryTeller
Nov 12 '18 at 12:59














@Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
– StoryTeller
Nov 12 '18 at 13:01






@Oliv - Yes, sizeof(A). It was an entirely different question with that typo. But whatever, if it was "obvious".
– StoryTeller
Nov 12 '18 at 13:01














1 Answer
1






active

oldest

votes


















8















Can a concept evaluation depend on where it is evaluated?




Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.



As a result, this:



template<class T>
concept Complete = sizeof(T) == sizeof(T);

struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);


is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.






share|improve this answer





















  • Thanks! Could you have a look at this question too?
    – Oliv
    Nov 12 '18 at 18:50








  • 1




    Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
    – Davis Herring
    Nov 12 '18 at 19:40











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260099%2fcan-a-concept-evaluation-depend-on-where-it-is-evaluated%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8















Can a concept evaluation depend on where it is evaluated?




Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.



As a result, this:



template<class T>
concept Complete = sizeof(T) == sizeof(T);

struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);


is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.






share|improve this answer





















  • Thanks! Could you have a look at this question too?
    – Oliv
    Nov 12 '18 at 18:50








  • 1




    Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
    – Davis Herring
    Nov 12 '18 at 19:40
















8















Can a concept evaluation depend on where it is evaluated?




Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.



As a result, this:



template<class T>
concept Complete = sizeof(T) == sizeof(T);

struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);


is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.






share|improve this answer





















  • Thanks! Could you have a look at this question too?
    – Oliv
    Nov 12 '18 at 18:50








  • 1




    Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
    – Davis Herring
    Nov 12 '18 at 19:40














8












8








8







Can a concept evaluation depend on where it is evaluated?




Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.



As a result, this:



template<class T>
concept Complete = sizeof(T) == sizeof(T);

struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);


is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.






share|improve this answer













Can a concept evaluation depend on where it is evaluated?




Yes. This was explicitly discussed during core wording review when merging Concepts into the working draft. The concept is re-evaluated every time.



As a result, this:



template<class T>
concept Complete = sizeof(T) == sizeof(T);

struct A;
static_assert(!Complete<A>);
struct A {};
static_assert(Complete<A>);


is well-formed. In other words, we don't "memoize" concepts in the same way we "memoize" template instantiations.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 18:43









BarryBarry

178k18307563




178k18307563












  • Thanks! Could you have a look at this question too?
    – Oliv
    Nov 12 '18 at 18:50








  • 1




    Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
    – Davis Herring
    Nov 12 '18 at 19:40


















  • Thanks! Could you have a look at this question too?
    – Oliv
    Nov 12 '18 at 18:50








  • 1




    Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
    – Davis Herring
    Nov 12 '18 at 19:40
















Thanks! Could you have a look at this question too?
– Oliv
Nov 12 '18 at 18:50






Thanks! Could you have a look at this question too?
– Oliv
Nov 12 '18 at 18:50






1




1




Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
– Davis Herring
Nov 12 '18 at 19:40




Note that it’s ill-formed NDR to have a template whose instantiations might be different because of such changes between two of its (potential) points of instantiation. (Mostly this affects function templates.)
– Davis Herring
Nov 12 '18 at 19:40


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260099%2fcan-a-concept-evaluation-depend-on-where-it-is-evaluated%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation