Click here to Skip to main content
15,893,923 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.

 
GeneralRe: On Page 1, in the news Pin
CDP180210-Nov-16 1:33
CDP180210-Nov-16 1:33 
GeneralRe: On Page 1, in the news Pin
OriginalGriff10-Nov-16 1:44
mveOriginalGriff10-Nov-16 1:44 
GeneralRe: On Page 1, in the news Pin
lopatir10-Nov-16 2:05
lopatir10-Nov-16 2:05 
GeneralRe: On Page 1, in the news Pin
Nelek10-Nov-16 3:03
protectorNelek10-Nov-16 3:03 
GeneralRe: On Page 1, in the news Pin
Foothill10-Nov-16 3:23
professionalFoothill10-Nov-16 3:23 
GeneralRe: On Page 1, in the news Pin
Marc Clifton10-Nov-16 3:30
mvaMarc Clifton10-Nov-16 3:30 
GeneralRe: On Page 1, in the news Pin
dandy7210-Nov-16 4:12
dandy7210-Nov-16 4:12 
GeneralFluent in C++ Pin
Pete O'Hanlon10-Nov-16 0:42
mvePete O'Hanlon10-Nov-16 0:42 
So, as some of the longer term viewers may know, I used to be a C++ developer; way back in the mists of time. I loved C++ and then the new girl came to town and seduced me with her wiles. No longer would I put up with manual memory management, iterating over for statements when I could use the seductive foreach.

Well, I have recently started getting quite heavily back into C++ using the newer additions to the language such as auto and for (auto index : my_vector) as a foreach. The features that are available now are great and C++ really has matured. So much so that I'm using it to write some drone software. I'm a big fan of fluent interfaces so I thought I'd play around and see how they work in C++ to see if I still want to keep with the new C++ and damn it, it's so straightforward.
C++
#pragma once
#include <librealsense/rs.hpp>

class RealSenseStream
{
public:
  explicit RealSenseStream(rs::device* device)
  {
    this->device = device;
  }
  ~RealSenseStream()
  {
  }

  RealSenseStream &WithDepth(rs::preset preset)
  {
    device->enable_stream(rs::stream::depth, preset);
    return *this;
  }

  RealSenseStream &WithColor(rs::preset preset)
  {
    device->enable_stream(rs::stream::color, preset);
    return *this;
  }

private:
  rs::device* device;
};

This space for rent

GeneralRe: Fluent in C++ Pin
CDP180210-Nov-16 0:54
CDP180210-Nov-16 0:54 
GeneralRe: Fluent in C++ Pin
harold aptroot10-Nov-16 0:57
harold aptroot10-Nov-16 0:57 
GeneralRe: Fluent in C++ Pin
CDP180210-Nov-16 1:00
CDP180210-Nov-16 1:00 
GeneralRe: Fluent in C++ Pin
Pete O'Hanlon10-Nov-16 1:04
mvePete O'Hanlon10-Nov-16 1:04 
GeneralRe: Fluent in C++ Pin
Florian Rappl10-Nov-16 1:10
professionalFlorian Rappl10-Nov-16 1:10 
GeneralRe: Fluent in C++ Pin
CDP180210-Nov-16 1:18
CDP180210-Nov-16 1:18 
GeneralRe: Fluent in C++ Pin
Pete O'Hanlon10-Nov-16 1:39
mvePete O'Hanlon10-Nov-16 1:39 
GeneralRe: Fluent in C++ Pin
CDP180210-Nov-16 1:12
CDP180210-Nov-16 1:12 
GeneralRe: Fluent in C++ Pin
megaadam10-Nov-16 1:43
professionalmegaadam10-Nov-16 1:43 
GeneralRe: Fluent in C++ Pin
den2k8810-Nov-16 1:58
professionalden2k8810-Nov-16 1:58 
GeneralRe: Fluent in C++ Pin
megaadam10-Nov-16 3:49
professionalmegaadam10-Nov-16 3:49 
GeneralRe: Fluent in C++ Pin
den2k8810-Nov-16 4:03
professionalden2k8810-Nov-16 4:03 
GeneralRe: Fluent in C++ Pin
Kirill Illenseer10-Nov-16 21:28
Kirill Illenseer10-Nov-16 21:28 
GeneralRe: Fluent in C++ Pin
Herbie Mountjoy11-Nov-16 1:23
professionalHerbie Mountjoy11-Nov-16 1:23 
GeneralRe: Fluent in C++ Pin
Anna-Jayne Metcalfe10-Nov-16 23:34
Anna-Jayne Metcalfe10-Nov-16 23:34 
GeneralRe: Fluent in C++ Pin
Pete O'Hanlon11-Nov-16 0:15
mvePete O'Hanlon11-Nov-16 0:15 
GeneralRe: Fluent in C++ Pin
Anna-Jayne Metcalfe11-Nov-16 4:07
Anna-Jayne Metcalfe11-Nov-16 4:07 

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.