Commit a11346ba authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+7 −0
Changes for Modern C++ Design Patterns - Working Files/Chapter 1/No Work Files.rtf: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0 No work files for this lesson...}
 No newline at end of file
+7 −0
Changes for Modern C++ Design Patterns - Working Files/Chapter 2/No Work Files.rtf: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0 No work files for this lesson...}
 No newline at end of file
+19 −0
Changes for Modern C++ Design Patterns - Working Files/Chapter 3/CRTP/crtp1.h: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
#ifndef CRTP1_H
#define CRTP1_H

class Base {
protected:
    virtual int get_value() const = 0;
public:
    virtual ~Base() {}
    int return_data() const { return this->get_value(); }
};

class Derived : public Base {
private:
    int get_value() const override {
        return 10;
    }
};

#endif //CRTP1_H
+20 −0
Changes for Modern C++ Design Patterns - Working Files/Chapter 3/CRTP/crtp2.h: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
#ifndef CRTP2_H
#define CRTP2_H

template<typename D>
class Base2 {
public:
    D& derived() {
        return static_cast<D&>(*this);
    }

    int return_data() { return derived().get_value(); }

};

class Derived2 : public Base2<Derived2> {
public:
    int get_value() const { return 100; }
};

#endif //CRTP2_H
+10 −0
Changes for Modern C++ Design Patterns - Working Files/Chapter 3/CRTP/main.cpp: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
#include <iostream>

#include "crtp2.h"

int main() {
    Base2<Derived2> b2;
    std::cout << b2.return_data() <<std::endl;

    return 0;
}
 No newline at end of file
Loading