20 questions
0 votes
1 answer
94 views
Cannot call inline fun SearchView.OnQueryTextListener from onCreateOptionsMenu
In this app I tried to implement SearchView.OnQueryTextListener in separate kotlin file like this import androidx.appcompat.widget.SearchView inline fun SearchView.OnQueryTextListener(crossinline ...
2 votes
3 answers
384 views
inline methods and code readability in modern C++ [closed]
Alright, so sometimes my "coding brain" skips a gear; once in a while you can hear the gears grind. (For instance, every once in a while I write class Foo : Bar {} before reminding myself that's not ...
17 votes
3 answers
20k views
Are inline operators good?
Is there any difference between operators and other methods to make inline in C++? I have searched for it, but it is not a common question, as I see. Has anyone a strong reason to use it or avoid? ...
0 votes
2 answers
201 views
How to do a quick inline method with conditional?
This is what I'd like to do: string x = if(true) "String Val" else "No String Val"; Is that possible?
38 votes
3 answers
38k views
C++ template and inline
When I'm writing a simple (non-template) class, if the function implementation is provided "right in place", it's automatically treated as inline. class A { void InlinedFunction() { int a = 0; } ...
3 votes
3 answers
597 views
C++ inline methods with same if statements
i'm writting handler for OpenGL texture and i'm thinking about safety and performance. Which level of optimization should remove marked if statements? struct Texture2D { GLuint ID; inline ...
0 votes
3 answers
264 views
Inlined constructors? Explain this behavior[C++]
Consider this code #include <iostream> #include <cstdio> using namespace std; class Dummy { public: Dummy(); }; inline Dummy::Dummy() { printf("Wow! :Dummy rocks\n"); } int ...
2 votes
1 answer
335 views
At what stage does the compiler perform inlining?
here is a small question about inline functions in c++. At what stage of the compilation in C++ are the inline functions actually inlined at the call? how does that basically work. lets say if the ...
0 votes
3 answers
783 views
How can I avoid repeating code with inline functions?
I have repeating code in my work, and I want to get rid of it, so I know that in C++ it is not good idea to use macro, but instead I must use inline function, is it good idea to use this function as ...
33 votes
4 answers
22k views
Why can't c# use inline anonymous lambdas or delegates? [duplicate]
I hope I worded the title of my question appropriately. In c# I can use lambdas (as delegates), or the older delegate syntax to do this: Func<string> fnHello = () => "hello"; Console....
15 votes
3 answers
809 views
Can method inlining optimization cause race conditions?
As seen in this question: Raising C# events with an extension method - is it bad? I'm thinking of using this extension method to safely raise an event: public static void SafeRaise(this EventHandler ...
2 votes
3 answers
643 views
Inline functions in dotNet 3.0+ with C#?
I am looking for a trick in newer dotnets where I can use inline functions that return a string value. Here's what I have: var split = new[] { " " }; var words = SearchTextBox.Text.Trim().Split( ...
7 votes
1 answer
2k views
If optimizations are enabled will the JIT always inline this method?
I am not expecting a definite yes or no. Any knowledge you might have I will consider as an answer. private String CalculateCharge(Nullable<Decimal> bill, Nullable<Decimal> rate) { ...
40 votes
8 answers
15k views
Inlining in Java
In C++ I can declare a method "inline" and the compiler is likely to inline it. As far as I understand there is no such keyword in Java. Inlining is done if the JVM decides to do so? Can I influence ...
0 votes
7 answers
2k views
Calling inline functions C++
I have an inline member function defined under class MyClass int MyClass::myInlineFunction(); This function is called from several places in my code. There are two ways to call this function Case 1: ...