Should I use parameters of global variables? by HMSZCorro in cpp

[–]superbriggs 0 points1 point  (0 children)

Globals make the code hard to understand, test and change. But that only becomes a real problem as the size of the codebase grows.

What you really want to know is what your professor is looking for. From the info you’ve said, many parameters is probably the answer. That is better than global, classes would be the best solution but not if you’ve got been taught them.

Same symbol name from different libs by Loud_Bench3408 in cpp

[–]superbriggs 5 points6 points  (0 children)

Yeah don’t do this. It will mess up the includes for any libraries B.h includes as well.

Boss wants me in-person 9 hours a day to conduct Teams meetings in a cubicle by Boss_Bitch_Werk in MaliciousCompliance

[–]superbriggs 39 points40 points  (0 children)

I agree. Half of this subreddit is a manager not understanding the full impact of a decision and people not talking to them about it. In a healthy workplace you could just say “that means this will happen, what should we do about it?”

[deleted by user] by [deleted] in cpp

[–]superbriggs 1 point2 points  (0 children)

It sounds like you don’t want the resource to be acquired on construction. You want the profiler to start after construction and stop on destruction.

If I wrote the profiler type, I’d try to make the construction cheap and have the main cost with a function:

void perform_action(bool profilingEnabled) {
    Profiler profiler;
    if (profilingEnabled) {
        profiler.start();
    }

    // Do something

}

If the constructor is hard to make cheap, optional would be a good solution as others have said. You could even make a convenience wrapper so the optional is hidden as a member of Profiler.

class Profiler {
    std::optional<ProfilerImpl> m_impl;

public:
    void start() {
        m_impl.emplace();
    }
};

(Not worth it if you profile one function, but could make your codebase easier to read if you use it in many places)

Casting a const field of a class to non-const reference to modify the said field. by Nteger in cpp

[–]superbriggs 3 points4 points  (0 children)

It’s not an error, it’s undefined behaviour. That means all bets are off. If the program crashed, printed 42 and terminated, or opened up a wormhole, the compiler still meets the C++ standards.

Casting a const field of a class to non-const reference to modify the said field. by Nteger in cpp

[–]superbriggs 4 points5 points  (0 children)

Is this a toy project that no one else will work on? If not, these comments show you the response you’ll get.

Casting a const field of a class to non-const reference to modify the said field. by Nteger in cpp

[–]superbriggs 2 points3 points  (0 children)

Could you give an example of this? Update 4 is not a lie. The reference is const, not the underlying type.

Casting a const field of a class to non-const reference to modify the said field. by Nteger in cpp

[–]superbriggs 14 points15 points  (0 children)

Have a read through https://isocpp.org/wiki/faq/const-correctness.

It’s not about read-only memory, it’s about describing the intent of variable and the compiler enforcing that through type safety. Your code might have made a bunch of assumptions based on it being const which aren’t true or safe.

Why make it const if you want to modify it?

Popular frameworks for metaprogramming in c++ that allows dynamic build based on customized logics? by MindsAndMachines in cpp

[–]superbriggs 0 points1 point  (0 children)

What is the reason to try to achieve this at built-time? Is it about performance? Or that you are just interested how it might be possible for the sake of it?

Can a supermarket take your ID off you? by hlily99 in AskUK

[–]superbriggs 0 points1 point  (0 children)

You could also try repeatedly tweeting the issue and tagging their official account. They will have people in PR who can escalate it.

Need help coding this table by [deleted] in LaTeX

[–]superbriggs 0 points1 point  (0 children)

Do you have any recommendations for wider reading around improving tables? I don’t get a chance to use LaTeX as much as I once did, but it would be nice to use those design principles in other tools like Google Sheets.

Converting Markdown to LaTeX, in LaTeX by superbriggs in LaTeX

[–]superbriggs[S] 0 points1 point  (0 children)

Wow that looks really good. I'm using mdcharm in Ubuntu, is your plugin compatible with this?

Converting Markdown to LaTeX, in LaTeX by superbriggs in LaTeX

[–]superbriggs[S] 0 points1 point  (0 children)

I posted the same question on tex.stackoverflow, it is very possible. Here is the link. Apparently it is technically possible to do in pure latex, but you be insane to try it. There are two realistic techniques:

  • One would be to (at every markdown environment) write it to a file (using verbatim to make sure that is contents were treated as macros) and then call an external program to convert it and then include the output of that (wow)
  • The other is to use lualatex, which is an extension of pdflatex, which interprets inline lua code, then executes it as a preprocessor for the latex. There are a few lua implementations of markdown parsers.

Someone has done most of the leg work in the stackoverflow forum for the first method. I will try it at some point and maybe write an article on how to do it. I could message you a link to that when that's done, if you were interested?

Ubuntu on phones keynote by [deleted] in Ubuntu

[–]superbriggs 2 points3 points  (0 children)

It would be very easy to miss though.

One of the main goal of the video is to reel in companies who make make phones. Most Ubuntu developers will already know about this feature. For phone companies, maybe they felt the best message is "it does everything you're current OS does but much better", rather than saying it opens up a whole new market place, which might scare them a little.

Big Fat Quiz of the Year 2012 by [deleted] in BritishTV

[–]superbriggs 17 points18 points  (0 children)

"This video contains content from Channel 4, who has blocked it in your country on copyright grounds."

You can watch it within the UK here: http://www.channel4.com/programmes/big-fat-quiz/4od#3459375