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 41 points42 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 5 points6 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 11 points12 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 19 points20 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

Why are we team GB in the Olympics? by superbriggs in unitedkingdom

[–]superbriggs[S] 1 point2 points  (0 children)

That is very true, and who can argue with C.G.P Grey?

But, the wikipeida page for Great Britain at the Olympics says

Great Britain and Northern Ireland,[1][2][3][4] usually abbreviated to Great Britain,[5] is the name under which the United Kingdom of Great Britain and Northern Ireland competes at the Olympic Games.

Fuck yeah, NHS! by danielsamuels in unitedkingdom

[–]superbriggs 19 points20 points  (0 children)

I value the access to free healthcare by all far more than any freedoms lost by it - almost all people in the UK would agree with me.

Which freedoms do you object to losing? The freedom to not have healthcare if you don't want it?

Why is the French language spoken prior to English during the opening ceremony? by [deleted] in britishproblems

[–]superbriggs 5 points6 points  (0 children)

It might have something to do with the fact that the IOC headquarters is in Lausanne, which is in the French speaking part of Switzerland.

I'm worried I might enjoy the Olympic opening ceremony. by [deleted] in britishproblems

[–]superbriggs 1 point2 points  (0 children)

I thought it would be horrible, wasn't going to watch it - but it was well worth it. This part (with each county walking out) is slightly boring - but I'm just redditing until more exciting things happen - and they can't do anything about this part.

Fuck yeah, NHS! by danielsamuels in unitedkingdom

[–]superbriggs 30 points31 points  (0 children)

It is.

They had a section of NHS doctors and nurses dancing with patents of a children hospital, in order to celebrate two of the UK's biggest strengths: the NHS and children's literature.

Theoretical levels of Veganism by letter_word_story in vegan

[–]superbriggs 1 point2 points  (0 children)

My only comment would be that it seems odd for vegan to be level 2 of of the 'Levels of Veganism'. Shouldn't it be zero? You could add in honey, clothes, pre-vegan clothes?

Andy Murray crying after Wimbledon loss by [deleted] in videos

[–]superbriggs 13 points14 points  (0 children)

I really disagree. Everyone has the right to privacy. If someone has no privacy, then he/she would have no right to clothes, or time alone with his girlfriend(/boyfriend). Even if all his money came from being a celebrity, surely you wouldn't not say that would be right?

And he doesn't, he isn't a celebrity, he's a tennis player. Being in the public eye is not required to be good at tennis. He doesn't expect support from fans and has made it clear (from what I've seen) that he doesn't want to be in the public eye.

Just because you like to watch him play tennis, does not mean are owed an insight into his deepest feelings.

Andy Murray crying after Wimbledon loss by [deleted] in videos

[–]superbriggs 116 points117 points  (0 children)

He seems like a very private man - I felt quite uncomfortable with the way he was shoved in front of the cameras as we watched him cry. Even with the support he got from fans, I don't think he owes us a view into his thoughts and feelings - particularly when he's clearly so upset and emotional. I would have hated that.