Posts

Showing posts from April, 2021

Lexicographic comparisons in C++

Lexicographic comparisons in C++: Link to Pluralsight article

C++ move semantics

  Move Semantics The following simple class will be used to illustrate move semantics and object lifecycle.  std::move  creates rvalue reference Float.h # pragma once class Float { public : Float ( float f ) ; //constructor Float ( const Float & f ) ; //copy constructor Float ( Float && f ) noexcept ; //move constructor Float & operator = ( const Float & rhs ) ; //copy assignment operator Float & operator = ( Float && rhs ) noexcept ; //move assignment operator ~ Float ( ) ; //destructor float getValue ( ) const ; //getter void setValue ( float f ) ; //setter friend void swap ( Float & first , Float & second ) noexcept ; //copy helper function void moveFrom ( Float & src ) noexcept ; //move helper function. Note param is lvalue reference float * m_flt ; //pointer to heap based float } ; Float.cpp # include <iostream> # include <utility> # include "