Click here to Skip to main content
15,112,453 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: New code in C? Where and why, versus C++? Pin
giulicard2-Mar-21 22:41
Membergiulicard2-Mar-21 22:41 
AnswerRe: New code in C? Where and why, versus C++? Pin
Martin ISDN3-Mar-21 0:40
MemberMartin ISDN3-Mar-21 0:40 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 1:34
mvahoney the codewitch3-Mar-21 1:34 
AnswerRe: New code in C? Where and why, versus C++? Pin
Behzad Sedighzadeh3-Mar-21 0:48
MemberBehzad Sedighzadeh3-Mar-21 0:48 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 1:29
mvahoney the codewitch3-Mar-21 1:29 
AnswerRe: New code in C? Where and why, versus C++? Pin
Stuart Dootson3-Mar-21 1:01
professionalStuart Dootson3-Mar-21 1:01 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 1:28
mvahoney the codewitch3-Mar-21 1:28 
GeneralRe: New code in C? Where and why, versus C++? Pin
Stuart Dootson3-Mar-21 2:10
professionalStuart Dootson3-Mar-21 2:10 
honey the codewitch wrote:
On that subject, how would you go about accepting a lambda as a parameter to a function without accepting std::function? (i'm pretty sure you'd need to make the accepting function a template but it would be cool if you didn't)


The way I generally do it on a non-constrained platform is with a template:
C++
template<class F>
int do_something(F&& f, int value)
{
   return f(value);
}

However - there is a C++ standard proposal paper for something called a function_view, which is intended as a lightweight alternative to std::function purely for passing functions as parameters. This blog article explains it more. I've seen other std:function alternatives as well - this one, here on CodeProject was one of the first I saw, IIRC.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 2:19
mvahoney the codewitch3-Mar-21 2:19 
GeneralRe: New code in C? Where and why, versus C++? Pin
Stuart Dootson3-Mar-21 2:24
professionalStuart Dootson3-Mar-21 2:24 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 2:29
mvahoney the codewitch3-Mar-21 2:29 
GeneralRe: New code in C? Where and why, versus C++? Pin
Stuart Dootson3-Mar-21 2:54
professionalStuart Dootson3-Mar-21 2:54 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 3:06
mvahoney the codewitch3-Mar-21 3:06 
AnswerRe: New code in C? Where and why, versus C++? Pin
Gary R. Wheeler3-Mar-21 3:57
MemberGary R. Wheeler3-Mar-21 3:57 
AnswerRe: New code in C? Where and why, versus C++? Pin
mischasan3-Mar-21 7:46
Membermischasan3-Mar-21 7:46 
GeneralRe: New code in C? Where and why, versus C++? Pin
honey the codewitch3-Mar-21 7:50
mvahoney the codewitch3-Mar-21 7:50 
AnswerRe: New code in C? Where and why, versus C++? Pin
Chad3F9-Mar-21 12:46
MemberChad3F9-Mar-21 12:46 
GeneralIs this right place? Pin
Nagy Vilmos2-Mar-21 3:14
professionalNagy Vilmos2-Mar-21 3:14 
GeneralRe: Is this right place? Pin
den2k882-Mar-21 3:16
professionalden2k882-Mar-21 3:16 
GeneralRe: Is this right place? Pin
OriginalGriff2-Mar-21 3:17
mveOriginalGriff2-Mar-21 3:17 
GeneralRe: Is this right place? Pin
Nagy Vilmos2-Mar-21 3:27
professionalNagy Vilmos2-Mar-21 3:27 
GeneralRe: Is this right place? Pin
OriginalGriff2-Mar-21 3:28
mveOriginalGriff2-Mar-21 3:28 
GeneralRe: Is this right place? Pin
Nagy Vilmos2-Mar-21 3:46
professionalNagy Vilmos2-Mar-21 3:46 
GeneralRe: Is this right place? Pin
OriginalGriff2-Mar-21 3:50
mveOriginalGriff2-Mar-21 3:50 
GeneralRe: Is this right place? Pin
W Balboos, GHB2-Mar-21 3:18
mveW Balboos, GHB2-Mar-21 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.