Are there any macros to determine if my code is being compiled to Windows? [duplicate]

[Edit: I assume you want to use compile-time macros to determine which environment you’re on. Maybe you want to determine if you’re running on Wine under Linux or something instead of Windows, but in general, your compiler targets a specific environment, and that is either Windows (DOS) or it isn’t, but it’s rarely (never?) both.] … Read more

Set a default value to a property

No, there is no built-in way to set the value of a property with metadata. You could use a factory of some sort that would build instances of a class with reflection and then that could set the default values. But in short, you need to use the constructors (or field setters, which are lifted … Read more

Solving random crashes

Try Valgrind (it’s free, open-source): The Valgrind distribution currently includes six production-quality tools: a memory error detector, two thread error detectors, a cache and branch-prediction profiler, a call-graph generating cache profiler, and a heap profiler. It also includes two experimental tools: a heap/stack/global array overrun detector, and a SimPoint basic block vector generator. It runs … Read more

“Roll-Back” or Undo Any Manipulators Applied To A Stream Without Knowing What The Manipulators Were [duplicate]

Yes. You can save the state and restore it: #include <iostream> #include <iomanip> using namespace std; int main() { std::ios state(NULL); state.copyfmt(std::cout); cout << “Hello” << hex << 42 << “\n”; // now i want to “roll-back” cout to whatever state it was in // before the code above, *without* having to know what modifiers … Read more

Entity Framework 4.1 InverseProperty Attribute

I add an example for the InversePropertyAttribute. It cannot only be used for relationships in self referencing entities (as in the example linked in Ladislav’s answer) but also in the “normal” case of relationships between different entities: public class Book { public int ID {get; set;} public string Title {get; set;} [InverseProperty(“Books”)] public Author Author … Read more

C# string interpolation-escaping double quotes and curly braces

It seems that you have missed escape for the products and query objects: $@”{{ “”name””:””{taskName}””, “”products””: [ {{“”product””: “”ndvi_image””, “”actions””: [“”mapbox””, “”processed””]}}, {{“”product””: “”true_color””, “”actions””: [“”mapbox””, “”processed””]}} ], “”recurring””:true, “”query””: {{ “”date_from””: “”{dateFromString}””, “”date_to””: “”{dateToString}””, “”aoi””: {polygon} }}, “”aoi_coverage_percentage””:90 }}”;

Why doesn’t this “undefined extern variable” result in a linker error in C++17?

Because the variable isn’t odr-used. You have a constexpr if there that always discards the branch that could use it. One of the points of constexpr if is that the discarded branch need not even compile, only be well-formed. That’s how we can place calls to non-existing member functions in a discarded branch.