Skip to content

Commit

Permalink
ci编译通过
Browse files Browse the repository at this point in the history
  • Loading branch information
zturn committed Jan 16, 2024
1 parent 4183005 commit de0efda
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build-run-homework.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Build and Run HomeWork
name: Build HomeWork

on:
workflow_dispatch:
# push:
# branches: [ "main" ]
push:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
env:
CXX_Compiler: g++-13

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=$CXX_Compiler

- name: Build
run: cmake --build ${{github.workspace}}/build

- name: Run
run: cmake --build ${{github.workspace}}/build --target run_all

# 有等待输入的程序
# - name: Run
# run: cmake --build ${{github.workspace}}/build --target run_all
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.17)
project(loser_homework)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(LoserHomeWork)

Expand All @@ -21,6 +21,7 @@ foreach(subdir ${homework_src_subdirs})
continue()
endif ()
get_cpp_files(${homework_src}/${subdir} cpp_file_list)
remove_use_modules_cpp("${cpp_file_list}" cpp_file_list)
remove_not_valid_target_name("${cpp_file_list}" valid_cpp_file_list)
set(hw_prefix "hw_${index}")
generate_cpp_files_targets_name("${valid_cpp_file_list}" target_list "${hw_prefix}")
Expand Down
14 changes: 13 additions & 1 deletion cmake/LoserHomeWork.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.17)

function(get_cpp_files path _file_list)
file(GLOB file_list "${path}/*.cpp")
file(GLOB file_list "${path}/*.cpp" "${path}/*.cxx" "${path}/*.cc")
set(${_file_list} ${file_list} PARENT_SCOPE)
endfunction()

Expand Down Expand Up @@ -40,6 +40,18 @@ function(remove_not_valid_target_name target_list _result_list)
set(${_result_list} ${target_list} PARENT_SCOPE)
endfunction()

function(remove_use_modules_cpp target_list _result_list)
foreach(target ${target_list})
file(READ ${target} file_content)
string(FIND "${file_content}" "import" import_found)
if(NOT import_found EQUAL -1)
message("use modules: ${target}")
list(REMOVE_ITEM target_list ${target})
endif()
endforeach()
set(${_result_list} ${target_list} PARENT_SCOPE)
endfunction()

function(add_cpp_executable_targets cpp_file_list target_list)
list(LENGTH cpp_file_list cpp_list_len)
list(LENGTH target_list target_list_len)
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/群友提交/第09题/xiaonewbee.cpp

This file was deleted.

2 changes: 2 additions & 0 deletions src/群友提交/第09题/xiaonewbee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
这个问题用名字查找来解释,如果不加`this`,首先在模板作用域内进行查找这个函数,如果没有,编译器认为是类外非成员函数。如果想调用父类模板的这个函数,需要加上作用域限定`X<T>::`或者`this->`
为什么模板函数不能直接使用父类的方法,名字查找依赖于模板参数,我认为是模板参数的实际类型确定要根据实际实例化的类型最终确定,如果父类有特化并且没有这个函数,那么实例化后这个就应该报错。再往下有点理解不了了。

0 comments on commit de0efda

Please sign in to comment.