16,468 questions
Score of 5
2 answers
326 views
How can I require a delegate/lambda to be static?
In some situations where I write a method that accepts a delegate as a parameter I find the need to require that the passed delegate must be static.
Here is an example that can serve as a working ...
Advice
0
votes
5
replies
125
views
Why do static const declaration within class and inline constexpr definition outside class work together
Look at this https://eel.is/c++draft/cmp#partialord-1
// valid values
static const partial_ordering less;
static const partial_ordering equivalent;
static const partial_ordering ...
Advice
0
votes
5
replies
219
views
Where exactly are static variables are located in Java
So I was looking up java interview questions and this one got me confused. I checked on Geek for Geeks and it says that they are stored in Metaspace with Class'es meta info and bytecodes while ...
Advice
0
votes
5
replies
144
views
Understanding the use of `'static` in RusTLS
As a (relative) novice at Rust, I am trying to understand the use of 'static in the RusTLS CommonState struct's peer_certificates method:
pub fn peer_certificates(&self) -> Option<&[...
Advice
0
votes
1
replies
138
views
What do people use for static website hosting these days?
Back in the day, we used to spend a lot of time configuring S3 with CloudFront to serve static sites at high speeds.
What are the common alternatives today, especially in the age of AI tooling?
Score of -3
1 answer
217 views
Performance comparison of where methods are called from [closed]
Is there any performance difference between having all of my static methods inside the main `Form` class, or having them separated out into their own class?
public partial class MyForm : Form
{
...
Score of 14
2 answers
834 views
static inline function in a header - redundant or not?
Is a static inline free function in a header redundant or useless?
Inline gives you "you can have more definitions with external linkage and as long as they're the same you don't violate ODR, ...
Score of 3
1 answer
213 views
Initialization order of static variables in class templates
What determines the order of initialization of static variables in class templates?
Consider for example the program as follows:
#include <iostream>
int f() { static int s = 0; return ++s; }
...
Score of 0
3 answers
306 views
Singleton using Lazy<T> vs Singleton using static field initializer [duplicate]
I am storing some settings for my application in a JSON file located alongside the application .exe. I want to load these settings only once, lazily, the first time one of them is needed. So for ...
Score of 0
1 answer
91 views
Problem with injecting value to the static variable
With the entered code here, I am trying to build a project on springboot. I am using AES encryption in my project. I am keeping the password (key) of AES in the application properties.
The variable ...
Score of 1
1 answer
202 views
Mockito spying on a class which contains a static method which calls another static method
I am trying to get a unit test to work using Mockito 5.14.2. The method I am trying to unit test is a static method (m1). Within the same class Myclass1 there is another static method (m2) which ...
Score of 0
1 answer
193 views
django-vite static assets being served but not loading on an Nginx deployment
I'm deploying a simple Django project on a local Ubuntu server VM running Docker (3 containers, Postgres, nginx and Django). The project uses a lot of HTMX and DaisyUI. On my dev environment they ...
Score of 2
1 answer
180 views
Why calling static field with the class is different from use just the variable name? [duplicate]
Consider the following code:
public class Example {
static { System.out.println(Example.value); }
static final int value = 7;
public static void main(final String[] args) { }
}
...
Score of 5
1 answer
203 views
Segmentation fault when trying to assign a global variable to a static reference variable
The following program gives segmentation fault.
#include <iostream>
using namespace std;
class A {
public:
static int& a;
};
int a = 42;
int& A::a = a;
int main() {
a = 100;
...
Score of 0
0 answers
62 views
Is initializing static const with a literal thread safe? [duplicate]
const std::string& GetLabel() {
static const std::string label = "label";
return label;
}
Is this thread safe? Does the standard guarantee that label will exist before GetLabel()...