id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
C++_Classes_Templates/15079_376_0.txt
public static const int Fibonacci(int n) { int a = 0; int b = 1; // In N steps compute Fibonacci sequence iteratively. for (int i = 0; i < n; i++) { int temp = a; a = b; b = temp + b; } return a; }
C++_Classes_Templates/1157_198_0.txt
Something went wrong.
C++_Classes_Templates/1157_170_0.txt
Something went wrong.
C++_Classes_Templates/15079_79_0.txt
* 👍 29 reactions * 😄 2 reactions
C++_Classes_Templates/15079_210_0.txt
Well, I think we can start with _all_ primitive types except object, these are pretty good candidates for constants when it comes to functions I don't really know what it would mean in C# because we can't mark functions with const and we can't know whether a function is deterministic.
C++_Classes_Templates/15079_770_0.txt
[ suggest: ` valueof ` operator to eval expression at compile time fsharp/fslang-suggestions#804 ](/fsharp/fslang-suggestions/issues/804)
C++_Classes_Templates/15079_298_0.txt
For a good example of abusing the JIT ability to optimize code based on constant expressions at runtime see the Microsoft Bond code. That source is a huge repository of all the weird things you can do when you have that (currently it is so difficult to follow that it is practically of no use).
C++_Classes_Templates/1157_15_0.txt
* [ Learning Pathways ](https://resources.github.com/learn/pathways) * [ White papers, Ebooks, Webinars ](https://resources.github.com) * [ Customer Stories ](https://github.com/customer-stories) * [ Partners ](https://partner.github.com)
C++_Classes_Templates/1157_207_0.txt
👍 1
C++_Classes_Templates/172624_35_0.txt
[ **BustTheCode** (10) ](/user/BustTheCode/)
C++_Classes_Templates/15079_290_0.txt
Copy link
C++_Classes_Templates/172624_39_0.txt
So when a key and scale type has been selected, the appropriate scale needs to be constructed using the above arrays. If the key selected is 'B' (whose index is 11) and the major scale is selected, the first note of the new B scale array is B. The following note, defined by the Major_Scale_Array, is 2 steps after B. So...
C++_Classes_Templates/15079_623_0.txt
And I agree with ` expanded set of const types ` , because today's soltution with decimals, ` arrays in attributes only ` and so on is really very ugly.
C++_Classes_Templates/Constexprlikekeyword_29_0.txt
Is there constexpr like functionality/syntax (that can be used at compile-time in functions in C++) available in C#?
C++_Classes_Templates/1157_114_0.txt
Quote reply
C++_Classes_Templates/Constexprlikekeyword_47_0.txt
constexpr int Fibonacci(int n) { //cout << "Executed Fib" << endl; switch (n) { case 0: return 0; case 1: return 1; default: return Fibonacci(n - 1) + Fibonacci(n - 2); }
C++_Classes_Templates/15079_396_0.txt
**[ iam3yal ](/iam3yal) ** commented Nov 11, 2016
C++_Classes_Templates/15079_41_0.txt
[ dotnet ](/dotnet) / **[ roslyn ](/dotnet/roslyn) ** Public
C++_Classes_Templates/Constexprlikekeyword_154_0.txt
[ ![](https://pubads.g.doubleclick.net/gampad/jump?iu=/6839/lqm.codeproject.site/ros&sz=728x90&c=564061) ](https://pubads.g.doubleclick.net/gampad/jump?iu=/6839/lqm.codeproject.site/ros&sz=728x90&c=564061)
C++_Classes_Templates/15079_109_0.txt
Copy link
C++_Classes_Templates/15079_457_0.txt
> [ @jnm2 ](https://github.com/jnm2) >
C++_Classes_Templates/15079_523_0.txt
[ ![@TonyValenti](https://avatars.githubusercontent.com/u/13609558?s=80&u=5599dc2a0097562e75f1a30b4956a0fcdc543a1d&v=4) ](/TonyValenti)
C++_Classes_Templates/15079_611_0.txt
###
C++_Classes_Templates/15079_601_0.txt
**[ iam3yal ](/iam3yal) ** commented Jan 30, 2017 •
C++_Classes_Templates/15079_416_0.txt
[ ![@iam3yal](https://avatars.githubusercontent.com/u/3756641?s=80&u=b853037d90aa1b20e6864477d91be927aeed062c&v=4) ](/iam3yal)
C++_Classes_Templates/1157_275_0.txt
0 replies
C++_Classes_Templates/1157_210_0.txt
0 replies
C++_Classes_Templates/15079_356_0.txt
That's the idea . :)
C++_Classes_Templates/1157_284_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/15079_37_0.txt
[ Sign in ](/login?return_to=https%3A%2F%2Fgithub.com%2Fdotnet%2Froslyn%2Fissues%2F15079)
C++_Classes_Templates/1157_370_0.txt
Why would i write a mutable vector using properties? That doesn't seem to make sense to me. Especially properties that are no-ops...
C++_Classes_Templates/15079_146_0.txt
**[ AdamSpeight2008 ](/AdamSpeight2008) ** commented Nov 8, 2016
C++_Classes_Templates/1157_397_0.txt
> For this particular nail, "pure" is just a big hammer. All that is needed is > "readonly" instance methods - methods that promise not to modify the object > on which they're invoked. Not that it would be easier to add "readonly" > methods...
C++_Classes_Templates/1157_441_0.txt
In [ https://github.com/dotnet/csharplang/pull/1165/files ](https://github.com/dotnet/csharplang/pull/1165/files)
C++_Classes_Templates/C++_Classes_7_6.txt
ent changes in the wiki \[r\]") * [ FAQ ](/w/Cppreference:FAQ) * [ Offline version ](/w/Cppreference:Archives) ##### Toolbox * [ What links here ](/w/Special:WhatLinksHere/cpp/language/static "A list of all wiki pages that link here \[j\]") * [ Related changes ](/w/Special:RecentChangesLinked/cpp/language/st...
C++_Classes_Templates/1157_520_0.txt
---
C++_Classes_Templates/Constexprlikekeyword_2_0.txt
[ Sign in ](javascript:;)
C++_Classes_Templates/Constexprlikekeyword_100_0.txt
PowerShell
C++_Classes_Templates/15079_11_0.txt
* [ Enterprise ](https://github.com/enterprise) * [ Teams ](https://github.com/team) * [ Startups ](https://github.com/enterprise/startups) * [ Education ](https://education.github.com)
C++_Classes_Templates/Constexprlikekeyword_48_0.txt
and I can check in the main to ensure the function is correct by doing something like:
C++_Classes_Templates/Constexprlikekeyword_50_0.txt
That means I do not have to wait till run time to evaluate if the Fibonacci function will work. It is like a simple test at a compile-time. I am asking if I can do thing kind of thing in C#.
C++_Classes_Templates/172624_50_0.txt
#include <array>
C++_Classes_Templates/15079_473_0.txt
One of the examples used a few times is a real limitation in the language - Attribute parameter values. Since they want const or similar "defined as known values" arguments, not just "known values", or "knowable values".
C++_Classes_Templates/15079_52_0.txt
# [Umbrella] How would you imagine constexpr in C#? #15079
C++_Classes_Templates/C++_Classes_0_7.txt
reference.com/support) * [ Recent changes ](/w/Special:RecentChanges "A list of recent changes in the wiki \[r\]") * [ FAQ ](/w/Cppreference:FAQ) * [ Offline version ](/w/Cppreference:Archives) ##### Toolbox * [ What links here ](/w/Special:WhatLinksHere/cpp/language "A list of all wiki pages that link here ...
C++_Classes_Templates/1157_556_0.txt
* [ Terms ](https://docs.github.com/site-policy/github-terms/github-terms-of-service) * [ Privacy ](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement) * [ Security ](https://github.com/security) * [ Status ](https://www.githubstatus.com/) * [ Docs ](https://docs.github.com/) * [ Contact ](ht...
C++_Classes_Templates/15079_684_0.txt
Sorry, something went wrong.
C++_Classes_Templates/172624_32_0.txt
Create a class that provides another layer to the data , with a method or two to do the circular thing is enough .
C++_Classes_Templates/C++_Classes_4_0.txt
##### [ cppreference.com ](/) [ Log in ](/mwiki/index.php?title=Special:UserLogin&returnto=cpp%2Flanguage%2Fnested+types "You are encouraged to log in; however, it is not mandatory \[o\]") ##### Namespaces * [ Page ](/w/cpp/language/nested_types "View the content page \[c\]") * [ Discussion ](/w/Talk:cpp/langu...
C++_Classes_Templates/gcc_bugs_1_0.txt
GCC Bugzilla – Bug 32143 decl rtl generated with incorrect visibility Last modified: 2021-09-17 00:10:30 UTC * [ Home ](./) * | [ New ](enter_bug.cgi?product=gcc) * | [ Browse ](describecomponents.cgi) * | [ Search ](query.cgi) * | [ [?] ](page.cgi?id=quicksearch.html "Quicksearch Help") * | [ Repor...
C++_Classes_Templates/15079_276_0.txt
---
C++_Classes_Templates/15079_614_0.txt
> You could say that about simpler examples as well, right? > I mean what would be the advantage of having Pow(2,3) or fib(...) > calculated at compiletime?
C++_Classes_Templates/1157_204_0.txt
---
C++_Classes_Templates/15079_429_0.txt
Sorry, something went wrong.
C++_Classes_Templates/172624_55_0.txt
---|---
C++_Classes_Templates/15079_64_0.txt
**[ iam3yal ](/iam3yal) ** commented Nov 8, 2016 •
C++_Classes_Templates/1157_92_0.txt
Perhaps make a new attribute.
C++_Classes_Templates/15079_60_0.txt
## Comments
C++_Classes_Templates/15079_701_0.txt
[ @Pzixel ](https://github.com/Pzixel) Sure but I'm not arguing, I'm just trying to explain to you what I meant by _constant function_ because you thought I was speaking about it in the context of mathematics and I wasn't.
C++_Classes_Templates/15079_680_0.txt
> A special case of pure functions is constant functions. A pure function that > does not access global memory, but only its parameters, is called a constant > function. This is because the function, being unrelated to the state of > global memory, will always return the same value when given the same > parameters. The...
C++_Classes_Templates/172624_102_0.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
C++_Classes_Templates/1157_493_0.txt
Because of multi-threaded access, of course, the class requires synchronization. Since there is no way to prove whether ` DrawShips() ` will modify ` Universe ` state, the code is forced to use exclusive locking. This pretty much kills any performance gains one would hope from multithreading. In some games, this has en...
C++_Classes_Templates/1157_255_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/172624_61_0.txt
> Originally I was going to iterate using a simple for loop or while loop.
C++_Classes_Templates/1157_236_0.txt
[ @alrz ](https://github.com/alrz) ,
C++_Classes_Templates/Constexprlikekeyword_61_0.txt
![](https://www.codeproject.com/script/Ratings/Images/star-fill-md.png)
C++_Classes_Templates/gcc_bugs_3_1.txt
[ Known to work: ](page.cgi?id=fields.html#cf_known_to_work "Known versions for which the issue is not reproducible.") | [ Known to fail: ](page.cgi?id=fields.html#cf_known_to_fail "Known versions for which the issue is reproducible.") | [ Last reconfirmed: ](page.cgi?id=fields.html#cf_reconfirmed_on "Last time t...
C++_Classes_Templates/15079_750_0.txt
* 👍 2 reactions
C++_Classes_Templates/1157_421_0.txt
Comment options
C++_Classes_Templates/1157_80_0.txt
---
C++_Classes_Templates/15079_563_0.txt
Copy link
C++_Classes_Templates/1157_23_0.txt
# Search code, repositories, users, issues, pull requests...
C++_Classes_Templates/15079_670_0.txt
---
C++_Classes_Templates/1157_509_0.txt
Comment options
C++_Classes_Templates/C++_Classes_7_4.txt
efinition) };   int S::a[10]; // definition, complete type struct Foo {}; Foo S::x; // definition, complete type S S::s; // definition, complete type However, if the declaration uses [ ` constexpr ` ](/w/cpp/language/constexpr "cpp/language/constexpr") or [ ` inline ` ](/w/cpp/languag...
C++_Classes_Templates/15079_719_0.txt
[ ![@iam3yal](https://avatars.githubusercontent.com/u/3756641?s=80&u=b853037d90aa1b20e6864477d91be927aeed062c&v=4) ](/iam3yal)
C++_Classes_Templates/15079_745_0.txt
From a practical point of view, the compilation will either finish before the server is rebooted, or it won't. If it doesn't finish before it gets wiped out by a reboot, it doesn't matter that it would have finished with a bit more time or not. Assume that the developer is ok with however long it takes.
C++_Classes_Templates/1157_277_0.txt
# {{title}}
C++_Classes_Templates/172624_47_0.txt
---|---
C++_Classes_Templates/15079_683_0.txt
All reactions
C++_Classes_Templates/1157_482_0.txt
0 replies
C++_Classes_Templates/15079_208_0.txt
[ @Unknown6656 ](https://github.com/Unknown6656)
C++_Classes_Templates/Constexprlikekeyword_38_0.txt
[ Benktesh Sharma ](/script/Membership/View.aspx?mid=11073155)
C++_Classes_Templates/15079_242_0.txt
Copy link
C++_Classes_Templates/1157_523_0.txt
All reactions
C++_Classes_Templates/1157_22_0.txt
Search or jump to...
C++_Classes_Templates/1157_345_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/1157_268_0.txt
3. It's certainly not annotated with a ` Pure ` attribute.
C++_Classes_Templates/1157_98_0.txt
Comment options
C++_Classes_Templates/15079_335_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_178_0.txt
👍 2 aluanhaddad and wendyn-projects reacted with thumbs up emoji
C++_Classes_Templates/1157_399_0.txt
---
C++_Classes_Templates/15079_778_0.txt
Labels
C++_Classes_Templates/1157_158_0.txt
Quote reply
C++_Classes_Templates/1157_232_0.txt
Something went wrong.
C++_Classes_Templates/Constexprlikekeyword_127_0.txt
[ Forgot your password? ](https://www.codeproject.com/script/Membership/SendPassword.aspx?rp=/)
C++_Classes_Templates/1157_298_0.txt
---
C++_Classes_Templates/Constexprlikekeyword_22_0.txt
![](https://www.codeproject.com/script/Ratings/Images/star-empty-md.png)
C++_Classes_Templates/1157_164_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/15079_442_0.txt
Copy link