-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dd75b5
commit 8c9d577
Showing
11 changed files
with
492 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} // ←ここで、デストラクタが呼ばれる | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.