Home>
struct S {
array<int, 1000>vals;
constexpr S (int _val): vals ({_ val}) {}
};
struct T {
int val;
static constexpr S stk = S (100);
// static const S stk = S (100);
T (int i): val (stk.vals [i]) {}
void set (int i) {val = stk.vals [i];}
};
I understand thatstatic const S stk = S (100);
is not available for the above code, butstatic constexpr S stk = S (100);
I didn't know why using code>did not cause an error.
-
Does
static constexpr S stk = S (100);
exist at runtime?T :: stk
is used in two places. Willarray
be generated in two places?vals
-
Answer # 1
Related articles
- c ++ - difference in comparison operation between insert, select and bubble sort
- In-depth analysis of the difference between static and templates in springboot
- [javascript] difference between let and const when declaring a function
- The difference between let and const in ES6
- dart: difference between final and const
- c ++ - difference between int and int
- The difference between define () and const in PHP
- c ++ - i want to know the difference between the light information of the vertex information and the material information direct
- What is the difference between CDN, SCDN and DCDN for website acceleration? how to choose?
- [java] difference between next () and nextline () of scanner
- [c ++] static linking of libraries and their use
- difference between ftp and ftpexe of java apach commons
- javascript - difference between js direct definition and external definition
- html - what is the difference between div and ul? if you specify list-style: none, you may think div is fine i want to know the
- difference when c ++ variable declaration is made inside and outside of main
- Learn the difference between Python str () and repr () through examples
- Explain the difference between atan and atan2 under the math module in python
- xml - difference between "@ style/~" and "? attr/~" when style is specified
- Simple understanding of the difference between MySQL union all and union
- Learn the difference between Java Integer class and int by example
Related questions
- c ++ - about imgui's imguitreenodeflags_notreepushonopen
- about c ++ structures
- c ++ - are there any differences between the following constants?
- c ++ - aoj judge doesn't work
- c ++ - the queue does not work well
- c ++ - operation of range for statement (for (:))
- c ++ - why isn't the inherited method called?
- c ++ - how to make a meta function that only materializes a vector
- c ++ - how to use metaprogramming
- c ++ - basic questions about iterators
stk
is ODR-used (written, addressed, or bound to a reference). If not, it may not exist.In addition, I feel that it was impossible to write without taking a reference, so I think that it will be ODR-use if you bind a real reference or take an address.
static constexpr
is implicitly specified asinline
, so there is only one entity.Reference