update ci, cmake, conan
This commit is contained in:
parent
50ded04922
commit
e62d87432f
15 changed files with 15217 additions and 252 deletions
|
@ -1,37 +1,31 @@
|
|||
version: "{branch} #{build}"
|
||||
|
||||
build: false
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
build:
|
||||
parallel: true
|
||||
|
||||
environment:
|
||||
PYTHON: "C:\\Python37"
|
||||
|
||||
CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
||||
CONAN_BUILD_POLICY: "missing"
|
||||
CONAN_USERNAME: "steakhal"
|
||||
CONAN_CHANNEL: "stable"
|
||||
CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
||||
|
||||
matrix:
|
||||
- MINGW_CONFIGURATIONS: '7@x86_64@seh@posix, 7@x86@dwarf2@posix, 8@x86_64@seh@posix, 8@x86@dwarf2@posix'
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CONAN_VISUAL_VERSIONS: 15
|
||||
CONAN_BUILD_TYPES: Release
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CONAN_VISUAL_VERSIONS: 15
|
||||
CONAN_BUILD_TYPES: Debug
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CONAN_VISUAL_VERSIONS: 16
|
||||
CONAN_BUILD_TYPES: Release
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CONAN_VISUAL_VERSIONS: 16
|
||||
CONAN_BUILD_TYPES: Debug
|
||||
- GENERATOR: "Visual Studio 15 2017"
|
||||
|
||||
before_build:
|
||||
- if exist build RMDIR /S /Q build
|
||||
- if not exist build mkdir build
|
||||
- cd build
|
||||
- cmake -G "%GENERATOR%" -A %PLATFORM% ..
|
||||
|
||||
install:
|
||||
- set PATH=%PATH%;%PYTHON%/Scripts/
|
||||
- pip.exe install conan --upgrade
|
||||
- pip.exe install conan_package_tools bincrafters_package_tools
|
||||
- conan user
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION%
|
||||
|
||||
test_script:
|
||||
- python .ci/build.py
|
||||
- ctest --output-on-failure -C %CONFIGURATION%
|
||||
|
|
13
.ci/build.py
13
.ci/build.py
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from cpt.packager import ConanMultiPackager
|
||||
|
||||
if __name__ == "__main__":
|
||||
options = { 'nameof:build_tests': True, 'nameof:build_examples': True }
|
||||
always_true = lambda build: True
|
||||
|
||||
builder = ConanMultiPackager()
|
||||
builder.add_common_builds()
|
||||
builder.update_build_if(always_true, new_options = options)
|
||||
builder.run()
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
brew update || brew update
|
||||
brew outdated pyenv || brew upgrade pyenv
|
||||
brew install pyenv-virtualenv
|
||||
brew install cmake || brew upgrade cmake || true
|
||||
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
pyenv install 3.7.1
|
||||
pyenv virtualenv 3.7.1 conan
|
||||
pyenv rehash
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
pip install conan --upgrade
|
||||
pip install conan_package_tools bincrafters_package_tools
|
||||
|
||||
conan user
|
12
.ci/run.sh
12
.ci/run.sh
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
python .ci/build.py
|
138
.travis.yml
138
.travis.yml
|
@ -1,74 +1,100 @@
|
|||
env:
|
||||
global:
|
||||
- CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
||||
- CONAN_BUILD_POLICY: "missing"
|
||||
- CONAN_USERNAME: "steakhal"
|
||||
- CONAN_CHANNEL: "stable"
|
||||
- CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
||||
|
||||
linux: &linux
|
||||
os: linux
|
||||
os: linux # Use linux unless specified otherwise.
|
||||
dist: xenial
|
||||
sudo: required
|
||||
language: python
|
||||
python: "3.6"
|
||||
services:
|
||||
- docker
|
||||
|
||||
osx: &osx
|
||||
os: osx
|
||||
language: generic
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- <<: *osx
|
||||
osx_image: xcode9.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
||||
- os: linux
|
||||
compiler: g++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-9
|
||||
env:
|
||||
- CXX_COMPILER=g++-9 CC_COMPILER=gcc-9
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode9.4
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
- g++-7
|
||||
env:
|
||||
- CXX_COMPILER=clang++-5.0 CC_COMPILER=clang-5.0
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode10.1
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-6.0
|
||||
packages:
|
||||
- clang-6.0
|
||||
- g++-7
|
||||
env:
|
||||
- CXX_COMPILER=clang++-6.0 CC_COMPILER=clang-6.0
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode10.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
packages:
|
||||
- clang-7
|
||||
- g++-7
|
||||
env:
|
||||
- CXX_COMPILER=clang++-7 CC_COMPILER=clang-7
|
||||
|
||||
- <<: *osx
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
packages:
|
||||
- clang-8
|
||||
- g++-7
|
||||
env:
|
||||
- CXX_COMPILER=clang++-8 CC_COMPILER=clang-8
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
osx_image: xcode10.3
|
||||
env:
|
||||
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
osx_image: xcode11
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=11.0
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
||||
env:
|
||||
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||
|
||||
install:
|
||||
- chmod +x .ci/install.sh
|
||||
- ./.ci/install.sh
|
||||
- export CC=${CC_COMPILER}
|
||||
- export CXX=${CXX_COMPILER}
|
||||
- JOBS=2 # Travis machines have 2 cores.
|
||||
|
||||
before_script:
|
||||
- rm -rf build
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- cmake -G "Unix Makefiles" ..
|
||||
|
||||
script:
|
||||
- chmod +x .ci/run.sh
|
||||
- ./.ci/run.sh
|
||||
- cmake --build . -- -j${JOBS}
|
||||
- ctest --output-on-failure -j${JOBS}
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
|
|
@ -4,8 +4,14 @@ project(nameof VERSION "0.9.0" LANGUAGES CXX)
|
|||
|
||||
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
|
||||
|
||||
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" OFF)
|
||||
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" OFF)
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set(IS_TOPLEVEL_PROJECT TRUE)
|
||||
else()
|
||||
set(IS_TOPLEVEL_PROJECT FALSE)
|
||||
endif()
|
||||
|
||||
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ${IS_TOPLEVEL_PROJECT})
|
||||
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ${IS_TOPLEVEL_PROJECT})
|
||||
|
||||
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
|
|
65
conanfile.py
65
conanfile.py
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from conans import ConanFile, tools, CMake
|
||||
from conans.model.version import Version
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
from conans import ConanFile
|
||||
|
||||
class NameofConan(ConanFile):
|
||||
name = 'nameof'
|
||||
|
@ -17,67 +14,19 @@ class NameofConan(ConanFile):
|
|||
'serialization',
|
||||
'reflection',
|
||||
'header-only',
|
||||
'introspection',
|
||||
'compile-time'
|
||||
)
|
||||
url = 'https://github.com/Neargye/nameof'
|
||||
homepage = 'https://github.com/Neargye/nameof'
|
||||
author = 'Daniil Goncharov <neargye@gmail.com>'
|
||||
license = 'MIT'
|
||||
generators = 'cmake_find_package'
|
||||
exports_sources = ['example/*', 'include/*', 'test/*', 'CMakeLists.txt', 'LICENSE']
|
||||
exports = ['LICENSE.md']
|
||||
_build_subfolder = 'build_subfolder'
|
||||
build_requires = []
|
||||
settings = ('os', 'compiler', 'build_type', 'arch')
|
||||
options = {
|
||||
'build_tests': [True, False],
|
||||
'build_examples': [True, False],
|
||||
}
|
||||
default_options = {
|
||||
'build_tests': False,
|
||||
'build_examples': False,
|
||||
}
|
||||
|
||||
@property
|
||||
def supports_compiler(self):
|
||||
compiler = str(self.settings.compiler)
|
||||
version = Version(str(self.settings.compiler.version))
|
||||
if compiler == 'Visual Studio' and version >= Version('15'):
|
||||
return True
|
||||
if compiler == 'gcc' and version >= Version('7'):
|
||||
return True
|
||||
if compiler == 'icc' and version >= Version('19'):
|
||||
return True
|
||||
if compiler == 'clang' and version >= Version('5'):
|
||||
return True
|
||||
if compiler == 'apple-clang' and version >= Version('9'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def requirements(self):
|
||||
if self.options.build_tests:
|
||||
self.build_requires.append('Catch2/2.9.1@catchorg/stable')
|
||||
|
||||
def configure(self):
|
||||
if not self.supports_compiler:
|
||||
raise ConanInvalidConfiguration('The specified compiler must support C++17')
|
||||
|
||||
def configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions['NAMEOF_OPT_BUILD_TESTS'] = self.options.build_tests
|
||||
cmake.definitions['NAMEOF_OPT_BUILD_EXAMPLES'] = self.options.build_examples
|
||||
cmake.configure(build_folder=self._build_subfolder)
|
||||
return cmake
|
||||
|
||||
def build(self):
|
||||
cmake = self.configure_cmake()
|
||||
cmake.build()
|
||||
if self.options.build_tests and not tools.cross_building(self.settings):
|
||||
cmake.test()
|
||||
exports_sources = ["include/*", "LICENCE"]
|
||||
exports = ["LICENSE"]
|
||||
no_copy_source = True
|
||||
|
||||
def package(self):
|
||||
cmake = self.configure_cmake()
|
||||
cmake.install()
|
||||
self.copy("include/*")
|
||||
self.copy("LICENSE", dst="licenses")
|
||||
|
||||
def package_id(self):
|
||||
self.info.header_only()
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
add_executable(example example.cpp)
|
||||
target_link_libraries(example PRIVATE nameof::nameof)
|
||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
target_compile_options(example
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wextra -pedantic-errors -Werror>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4 /WX>
|
||||
)
|
||||
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(OPTIONS /W4 /WX)
|
||||
if(HAS_PERMISSIVE_FLAG)
|
||||
set(OPTIONS ${OPTIONS} /permissive-)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(example example.cpp)
|
||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(example PRIVATE cxx_std_17)
|
||||
target_compile_options(example PRIVATE ${OPTIONS})
|
||||
target_link_libraries(example PRIVATE ${CMAKE_PROJECT_NAME})
|
||||
|
|
23
test/3rdparty/Catch2/LICENSE
vendored
Normal file
23
test/3rdparty/Catch2/LICENSE
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
15003
test/3rdparty/Catch2/catch.hpp
vendored
Normal file
15003
test/3rdparty/Catch2/catch.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,45 @@
|
|||
find_package(Catch2 REQUIRED)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag(-std=c++20 HAS_GNU_CPP20_FLAG)
|
||||
check_cxx_compiler_flag(/std:c++20 HAS_MSVC_CPP20_FLAG)
|
||||
set(HAS_CPP20 (HAS_GNU_CPP20_FLAG OR HAS_MSVC_CPP20_FLAG))
|
||||
set(SOURCES test.cpp)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(OPTIONS /W4 /WX)
|
||||
check_cxx_compiler_flag(/permissive HAS_PERMISSIVE_FLAG)
|
||||
if(HAS_PERMISSIVE_FLAG)
|
||||
set(OPTIONS ${OPTIONS} /permissive-)
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag(/std:c++20 HAS_CPP20_FLAG)
|
||||
check_cxx_compiler_flag(/std:c++latest HAS_CPPLATEST_FLAG)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||
|
||||
check_cxx_compiler_flag(-std=c++20 HAS_CPP20_FLAG)
|
||||
endif()
|
||||
|
||||
function(make_test target std)
|
||||
add_executable(${target} test.cpp)
|
||||
target_link_libraries(${target} PRIVATE Catch2::Catch2 nameof::nameof)
|
||||
add_executable(${target} ${SOURCES})
|
||||
target_compile_options(${target} PRIVATE ${OPTIONS})
|
||||
target_include_directories(${target} PRIVATE 3rdparty/Catch2)
|
||||
target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(${target} PRIVATE ${std})
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wextra -pedantic-errors -Werror>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4 /WX>
|
||||
)
|
||||
if(std)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(${target} PRIVATE /std:${std})
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE -std=${std})
|
||||
endif()
|
||||
endif()
|
||||
add_test(NAME ${target} COMMAND ${target})
|
||||
endfunction()
|
||||
|
||||
make_test(nameof-cpp17.t cxx_std_17)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpp17.t c++17)
|
||||
|
||||
if(HAS_CPP20 AND (cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES))
|
||||
make_test(nameof-cpp20.t cxx_std_20)
|
||||
if(HAS_CPP20_FLAG)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpp20.t c++20)
|
||||
endif()
|
||||
|
||||
if(HAS_CPPLATEST_FLAG)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpplatest.t c++latest)
|
||||
endif()
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// SOFTWARE.
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
#define NAMEOF_ENUM_RANGE_MIN -120
|
||||
#define NAMEOF_ENUM_RANGE_MAX 120
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package CXX)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_executable(test_package test_package.cpp)
|
||||
target_link_libraries(test_package PRIVATE CONAN_PKG::nameof)
|
||||
set_target_properties(test_package PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(test_package PRIVATE cxx_std_17)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
|
|
@ -1,27 +1,19 @@
|
|||
#include <nameof.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
struct SomeStruct {};
|
||||
|
||||
SomeStruct structvar;
|
||||
|
||||
int main() {
|
||||
// Compile-time.
|
||||
constexpr auto name = NAMEOF(structvar);
|
||||
static_assert("structvar" == name);
|
||||
|
||||
// Nameof.
|
||||
std::string_view res1 = NAMEOF(structvar);
|
||||
std::string_view res2 = NAMEOF(::structvar);
|
||||
|
||||
std::cout << res1 << '\n' << res2 << '\n';
|
||||
|
||||
using std::literals::string_view_literals::operator""sv;
|
||||
|
||||
bool success = (res1 == "structvar"sv) && (res2 == "structvar"sv);
|
||||
bool success = (res1 == "structvar") && (res2 == "structvar");
|
||||
|
||||
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue