Skip to content

Commit

Permalink
sakura-editor/sakura/pull/655説明用資材
Browse files Browse the repository at this point in the history
  • Loading branch information
berryzplus committed Dec 2, 2018
1 parent 0dd75b5 commit 8c9d577
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 0 deletions.
56 changes: 56 additions & 0 deletions cxx11_sample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# CMakeList.txt : CMake project for cxx11_sample, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.11)

include(GNUInstallDirs)

if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# CMake compile with /MT instead of /MD
# https://stackoverflow.com/questions/14172856/cmake-compile-with-mt-instead-of-md
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")


# setup pre-compiled header
function(target_use_pre_compile_header projectName PreCompiledHeader PreCompiledHeaderSource)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
#target_compile_options(${projectName} PRIVATE /Yu"${PreCompiledHeader}")
#set_source_files_properties(${PreCompiledHeaderSource}
# PROPERTIES
# COMPILE_FLAGS /Yc"${PreCompiledHeader}"
#)
endif(CMAKE_GENERATOR MATCHES "Visual Studio")
endfunction(target_use_pre_compile_header)


# define a variable of project name
set(projectName cxx11_sample)

# define a project name
project (${projectName})

# set the project as the startup project
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${projectName})

# define variables by file GLOB
file(GLOB_RECURSE cppHeaders src/*.h)
file(GLOB_RECURSE cppSources src/*.cpp)

# Add source to this project's executable.
add_executable(${projectName} ${cppHeaders} ${cppSources})

# add definitions
target_compile_definitions(${projectName} PUBLIC _CONSOLE UNICODE _UNICODE)

# add pre-compiled header to executable.
target_use_pre_compile_header(${projectName} StdAfx.h src/StdAfx.cpp)

# add library modules
target_link_libraries(${projectName} Shlwapi.lib)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties(${projectName}
PROPERTIES LINK_FLAGS "-municode")
endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
26 changes: 26 additions & 0 deletions cxx11_sample/src/CDoNotCopy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCDoNotCopy(void)
{
// CDoNotCopy
{
// コンストラクタ呼出し
CDoNotCopy obj1;

// コピーコンストラクタ呼出し
CDoNotCopy obj2(obj1);

// コピー演算子呼出し
CDoNotCopy obj3 = obj1;

// ムーブ演算子呼出し
CDoNotCopy obj4(std::move(obj1));

// ムーブ演算子呼出し
CDoNotCopy obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
26 changes: 26 additions & 0 deletions cxx11_sample/src/CDoNotCopyMixedStyle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCDoNotCopyMixedStyle(void)
{
// CDoNotCopyMixedStyle
{
// コンストラクタ呼出し
CDoNotCopyMixedStyle obj1;

// コピーコンストラクタ呼出し
CDoNotCopyMixedStyle obj2(obj1);

// コピー演算子呼出し
CDoNotCopyMixedStyle obj3 = obj1;

// ムーブ演算子呼出し
CDoNotCopyMixedStyle obj4(std::move(obj1));

// ムーブ演算子呼出し
CDoNotCopyMixedStyle obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
26 changes: 26 additions & 0 deletions cxx11_sample/src/CDoNotCopyOldStyle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCDoNotCopyOldStyle(void)
{
//CDoNotCopyOldStyle
{
// コンストラクタ呼出し
CDoNotCopyOldStyle obj1;

// コピーコンストラクタ呼出し
CDoNotCopyOldStyle obj2(obj1);

// コピー演算子呼出し
CDoNotCopyOldStyle obj3 = obj1;

// ムーブ演算子呼出し
CDoNotCopyOldStyle obj4(std::move(obj1));

// ムーブ演算子呼出し
CDoNotCopyOldStyle obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
26 changes: 26 additions & 0 deletions cxx11_sample/src/CDoNotCopySimple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCDoNotCopySimple(void)
{
// CDoNotCopySimple
{
// コンストラクタ呼出し
CDoNotCopySimple obj1;

// コピーコンストラクタ呼出し
CDoNotCopySimple obj2(obj1);

// コピー演算子呼出し
CDoNotCopySimple obj3 = obj1;

// ムーブ演算子呼出し
CDoNotCopySimple obj4(std::move(obj1));

// ムーブ演算子呼出し
CDoNotCopySimple obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
26 changes: 26 additions & 0 deletions cxx11_sample/src/CMovableTypeDoNotCopy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCMovableTypeDoNotCopy(void)
{
// CMovableTypeDoNotCopy
{
// コンストラクタ呼出し
CMovableTypeDoNotCopy obj1;

// コピーコンストラクタ呼出し
CMovableTypeDoNotCopy obj2(obj1);

// コピー演算子呼出し
CMovableTypeDoNotCopy obj3 = obj1;

// ムーブ演算子呼出し
CMovableTypeDoNotCopy obj4(std::move(obj1));

// ムーブ演算子呼出し
CMovableTypeDoNotCopy obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
26 changes: 26 additions & 0 deletions cxx11_sample/src/CSimple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "StdAfx.h"
#include "cxx11_sample.h"


void useCSimple(void)
{
//CSimple
{
// コンストラクタ呼出し
CSimple obj1;

// コピーコンストラクタ呼出し
CSimple obj2(obj1);

// コピー演算子呼出し
CSimple obj3 = obj1;

// ムーブ演算子呼出し
CSimple obj4(std::move(obj1));

// ムーブ演算子呼出し
CSimple obj5 = std::move(obj1);

} // ←ここで、デストラクタが呼ばれる
}
2 changes: 2 additions & 0 deletions cxx11_sample/src/StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// StdAfx.cpp : the Source-Code for Pre-Compiled Header
#include "StdAfx.h"
29 changes: 29 additions & 0 deletions cxx11_sample/src/StdAfx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// StdAfx.h : Include file for standard system include files,
// or project specific include files.

#pragma once

#define WIN32_LEAN_AND_MEAN

#define NO_MINMAX

#define _WIN32_WINNT 0x0602

#include <tchar.h>
#include <strsafe.h>
#include <Windows.h>
#include <Shlwapi.h>

#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <locale>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <regex>
#include <functional>
Loading

0 comments on commit 8c9d577

Please sign in to comment.