id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
C++_Classes_Templates/15079_270_0.txt
Closed
C++_Classes_Templates/15079_464_0.txt
* ❤️ 1 reaction
C++_Classes_Templates/15079_121_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_579_0.txt
> [ @asdfgasdfsafgsdfa ](https://github.com/asdfgasdfsafgsdfa) But it wouldn't > work for attributes that want a string in their constructor, right?
C++_Classes_Templates/1157_340_0.txt
1. Don't P/Invoke 2. Don't throw exceptions 3. <Insert other similar limitations>
C++_Classes_Templates/15079_206_0.txt
**[ iam3yal ](/iam3yal) ** commented Nov 9, 2016 •
C++_Classes_Templates/1157_259_0.txt
Comment options
C++_Classes_Templates/15079_482_0.txt
You can hand the compiler anything, but if it can't evaluate it from the info in scope it errors. Assembly is the scope I picked, because that seems kind-of like a "this" or "native scope".
C++_Classes_Templates/15079_782_0.txt
Milestone
C++_Classes_Templates/15079_168_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_414_0.txt
Sorry, something went wrong.
C++_Classes_Templates/1157_437_0.txt
Quote reply
C++_Classes_Templates/Constexprlikekeyword_1_0.txt
15,890,438 members
C++_Classes_Templates/172624_103_0.txt
#include <iostream> #include <string>
C++_Classes_Templates/15079_26_0.txt
[ Search syntax tips ](https://docs.github.com/search-github/github-code- search/understanding-github-code-search-syntax)
C++_Classes_Templates/15079_468_0.txt
###
C++_Classes_Templates/15079_110_0.txt
Author
C++_Classes_Templates/15079_181_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_472_0.txt
> Since we are really dealing with special case scenarios, working towards > (overly) generalized solutions is going in the wrong direction.
C++_Classes_Templates/15079_130_0.txt
Sorry, something went wrong.
C++_Classes_Templates/172624_24_0.txt
![](/img/link.png) Sep 2, 2015 at 4:03am UTC
C++_Classes_Templates/1157_351_0.txt
Something went wrong.
C++_Classes_Templates/Constexprlikekeyword_92_0.txt
Kotlin
C++_Classes_Templates/Constexprlikekeyword_70_0.txt
Comments
C++_Classes_Templates/1157_357_0.txt
---
C++_Classes_Templates/1157_407_0.txt
# {{title}}
C++_Classes_Templates/15079_183_0.txt
[ ![@Unknown6656](https://avatars.githubusercontent.com/u/8807985?s=80&u=0b85316fdb479595b2731ec5e1ab0d8c03bb3609&v=4) ](/Unknown6656)
C++_Classes_Templates/15079_303_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_197_0.txt
Where do we draw the line between constant expressions, which should be pre- computed by the compiler and expression, which should be evaluated at runtime?
C++_Classes_Templates/Constexprlikekeyword_156_0.txt
Layout: [ fixed ](/Questions/5163309/Constexpr-like-keyword-in- Csharp?PageFlow=FixedWidth "Fixed width layout") | [ fluid ](/Questions/5163309/Constexpr-like-keyword-in-Csharp?PageFlow=Fluid "Fluid layout")
C++_Classes_Templates/15079_308_0.txt
I am not familiar with C++. Hence maybe I have completely missed the topic.
C++_Classes_Templates/1157_64_0.txt
Why would this help? If methods are pure, there is no reason for the compiler to produce a copy of the struct. It can just use regular good old ` ldloca ` instead of copying the value. It only needs to produce a copy if the method that gets called is non- pure.
C++_Classes_Templates/15079_360_0.txt
👍 1 Unknown6656 reacted with thumbs up emoji
C++_Classes_Templates/1157_117_0.txt
It’s used about 600 times in .NET Framework, but virtually unused in .NET Core outside of System.Collections.Immutable.
C++_Classes_Templates/1157_376_0.txt
Comment options
C++_Classes_Templates/1157_392_0.txt
Something went wrong.
C++_Classes_Templates/15079_518_0.txt
Interesting, so this would be an feature exclusively to allow for "better code". The idea is being able to give constants (or constants derived from other constants though some expression) better names, and maintain the representation in the code how they were created (because rarely do people recognize 1.570... but th...
C++_Classes_Templates/15079_21_0.txt
* [ Pricing ](https://github.com/pricing)
C++_Classes_Templates/1157_386_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/15079_141_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_582_0.txt
public class Foo{ public readonly string Bar; public Foo(){ Bar = "Constructed"; } }
C++_Classes_Templates/1157_354_0.txt
[ ![](https://avatars.githubusercontent.com/u/9973420?s=64&v=4) mikedn ](/mikedn) Nov 30, 2017
C++_Classes_Templates/15079_91_0.txt
Contributor
C++_Classes_Templates/15079_790_0.txt
### Footer navigation
C++_Classes_Templates/1157_161_0.txt
> Why does pure functions have to be static?
C++_Classes_Templates/15079_232_0.txt
> Yeah, totally but just like I said previously it must have some fair limits > that will still allow some large computation but I don't know what would be > the right limit here and what optimizations the compiler can do, after all I > doubt we want very slow compilation times so this would be pretty > challenging.
C++_Classes_Templates/172624_11_0.txt
Still learning and have a long ways to go, so all feedback welcome. I've seen it written all over the internet that vectors are 'always' a better solution than arrays, but I'm not sure 'why' in this case.
C++_Classes_Templates/1157_385_0.txt
---
C++_Classes_Templates/Constexprlikekeyword_6_0.txt
[ Forgot your password? ](/script/Membership/SendPassword.aspx?rp=/Questions/5163309/Constexpr-like- keyword-in-Csharp)
C++_Classes_Templates/15079_36_0.txt
Cancel Create saved search
C++_Classes_Templates/172624_31_0.txt
Alligned data is super important and fast .
C++_Classes_Templates/172624_95_0.txt
![](/img/link.png) Sep 3, 2015 at 3:22pm UTC
C++_Classes_Templates/15079_574_0.txt
I want to be able to declare passing a Type Enum here, but I can't because it is not "const". The thing is though, within this context, Foo could be ~viewed as ` const int[] Foo { 0, 1 } ` . We could expect the compiler to know this, but that gets to be a big expectation for it to try to evaluate everything.
C++_Classes_Templates/15079_24_0.txt
Search
C++_Classes_Templates/172624_93_0.txt
Googling it provided some insight, but the structure and process is still confusing. So you have ` std::ostream& operator << ( std::ostream& stm, note n ) ` followed by brackets. I'm a bit confused as to what I'm looking at. Clearly it's not describing a class, and it doesn't appear to be describing a standard functio...
C++_Classes_Templates/15079_381_0.txt
Console.WriteLine("This app was built on {0} by {1} on {2}", BuildDate, BuildUser, BuildMachine);
C++_Classes_Templates/15079_315_0.txt
Copy link
C++_Classes_Templates/1157_51_0.txt
Nov 29, 2017 · 39 comments
C++_Classes_Templates/1157_68_0.txt
👍 28 ❤️ 4
C++_Classes_Templates/15079_77_0.txt
👍 29 Unknown6656, AdamSpeight2008, laicasaane, Joe4evr, redknightlois, pentp, Pzixel, jnm2, fitdev, eduard-malakhov, and 19 more reacted with thumbs up emoji 😄 2 lindexi and Pzixel reacted with laugh emoji
C++_Classes_Templates/15079_104_0.txt
So, what result is from 0 / 0 ?
C++_Classes_Templates/15079_410_0.txt
or more possible
C++_Classes_Templates/1157_313_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/1157_123_0.txt
Comment options
C++_Classes_Templates/15079_261_0.txt
> Why it needs to be sorted? :) > I guess what I'm asking is if you sort it how does this helps optimization?
C++_Classes_Templates/15079_784_0.txt
Development
C++_Classes_Templates/Constexprlikekeyword_145_0.txt
[ How to detect if a func. Is a constexpr? And mark other func. Constexpr depending on it? ](//www.codeproject.com/Questions/1108481/How-to-detect-if-a- func-Is-a-constexpr-And-mark-ot)
C++_Classes_Templates/1157_146_0.txt
Author
C++_Classes_Templates/15079_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/15079_606_0.txt
---
C++_Classes_Templates/1157_6_0.txt
* [ Actions Automate any workflow ](https://github.com/features/actions) * [ Packages Host and manage packages ](https://github.com/features/packages) * [ Security Find and fix vulnerabilities ](https://github.com/features/security) * [ Codespaces Instant dev environments ](https://github.com/features/codespace...
C++_Classes_Templates/15079_28_0.txt
We read every piece of feedback, and take your input very seriously.
C++_Classes_Templates/gcc_bugs_3_0.txt
GCC Bugzilla – Bug 52032 Function and class attributes should optionally take a bool parameter enabling them Last modified: 2012-01-30 21:13:37 UTC * [ Home ](./) * | [ New ](enter_bug.cgi?product=gcc) * | [ Browse ](describecomponents.cgi) * | [ Search ](query.cgi) * | [ [?] ](page.cgi?id=quicksearch....
C++_Classes_Templates/15079_438_0.txt
---
C++_Classes_Templates/15079_645_0.txt
[ ![@iam3yal](https://avatars.githubusercontent.com/u/3756641?s=80&u=b853037d90aa1b20e6864477d91be927aeed062c&v=4) ](/iam3yal)
C++_Classes_Templates/1157_215_0.txt
###
C++_Classes_Templates/15079_773_0.txt
[ ` is ` expression evaluating ` const ` expression should be considered constant dotnet/csharplang#6926 ](/dotnet/csharplang/issues/6926)
C++_Classes_Templates/15079_170_0.txt
Copy link
C++_Classes_Templates/Constexprlikekeyword_73_0.txt
[ Add a Solution ](/Questions/5163309/answer)
C++_Classes_Templates/1157_100_0.txt
Something went wrong.
C++_Classes_Templates/15079_492_0.txt
From an implementation perspective, a most basic approach could be an "intellisense assertion". The constexpr tells intellisense "don't check if this is a const, the compiler will". Within the compiler, evaluation of constexpr occurs early in the chain. Here again, a very simple approach could still provide benefit now...
C++_Classes_Templates/15079_126_0.txt
**[ AdamSpeight2008 ](/AdamSpeight2008) ** commented Nov 8, 2016
C++_Classes_Templates/1157_424_0.txt
Quote reply
C++_Classes_Templates/15079_42_0.txt
* [ Notifications ](/login?return_to=%2Fdotnet%2Froslyn) * [ Fork 3.9k ](/login?return_to=%2Fdotnet%2Froslyn) * [ Star 18.5k ](/login?return_to=%2Fdotnet%2Froslyn)
C++_Classes_Templates/172624_112_0.txt
operator<< ( std::cout, Re ) << '\n' ; // same as above
C++_Classes_Templates/15079_12_0.txt
By Solution
C++_Classes_Templates/1157_344_0.txt
---
C++_Classes_Templates/15079_555_0.txt
Methods that are marked with ` cost ` can still be evaluated at run-time if either one of their arguments isn't a constant.
C++_Classes_Templates/1157_455_0.txt
[ @alrz ](https://github.com/alrz)
C++_Classes_Templates/Constexprlikekeyword_79_0.txt
ASP.NET
C++_Classes_Templates/172624_106_0.txt
int main() { const std::string str = "hello world!\n" ;
C++_Classes_Templates/172624_77_0.txt
std::size_t pos = 0 ; for( std::size_t i = 0 ; i < result.size() ; ++i ) { result[i] = cs[ pos % cs.size() ] ; // *** note: modulo pos += steps[i] ; }
C++_Classes_Templates/172624_72_0.txt
constexpr chromatic_scale standard_chromatic_scale // extra pair of braces to suppress a silly warning { { A, AS_BF, B, C, CS_DF, D, DS_EF, E, F, FS_GF, G, GS_AF } } ;
C++_Classes_Templates/Constexprlikekeyword_82_0.txt
C++
C++_Classes_Templates/1157_405_0.txt
0 replies
C++_Classes_Templates/15079_412_0.txt
---
C++_Classes_Templates/Constexprlikekeyword_123_0.txt
Sign in to your account
C++_Classes_Templates/1157_245_0.txt
Comment options
C++_Classes_Templates/Constexprlikekeyword_33_0.txt
int main() { static_assert(Fibonacci(5) == 7, "Bad Program"); ///... }
C++_Classes_Templates/15079_286_0.txt
---