forked from TartanLlama/expected
Remove internal Conan package: there is now an external one
This commit is contained in:
@@ -5,6 +5,8 @@ Single header implementation of `std::expected` with functional-style extensions
|
||||
Clang + GCC: [](https://travis-ci.org/TartanLlama/expected)
|
||||
MSVC: [](https://ci.appveyor.com/project/TartanLlama/expected)
|
||||
|
||||
Available on [Vcpkg](https://github.com/microsoft/vcpkg/tree/master/ports/tl-expected) and [Conan](https://github.com/yipdw/conan-tl-expected).
|
||||
|
||||
[`std::expected`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0323r3.pdf) is proposed as the preferred way to represent object which will either have an expected value, or an unexpected value giving information about why something failed. Unfortunately, chaining together many computations which may fail can be verbose, as error-checking code will be mixed in with the actual programming logic. This implementation provides a number of utilities to make coding with `expected` cleaner.
|
||||
|
||||
For example, instead of writing this code:
|
||||
|
34
conanfile.py
34
conanfile.py
@@ -1,34 +0,0 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
|
||||
class ExpectedConan(ConanFile):
|
||||
name = "expected"
|
||||
version = "master"
|
||||
license = "CC0-1.0"
|
||||
author = "Simon Brand <tartanllama@gmail.com>"
|
||||
url = "https://github.com/TartanLlama/expected"
|
||||
description = "C++11/14/17 std::expected with functional-style extensions"
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
exports_sources = "*"
|
||||
|
||||
def source(self):
|
||||
tools.replace_in_file('CMakeLists.txt', 'project(tl-expected)',
|
||||
'''project(tl-expected)
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
''')
|
||||
|
||||
def configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
return cmake
|
||||
|
||||
def build(self):
|
||||
cmake = self.configure_cmake()
|
||||
cmake.build()
|
||||
|
||||
if not tools.cross_building(self.settings):
|
||||
self.run('%s/bin/tests' % self.build_folder)
|
||||
|
||||
def package(self):
|
||||
self.copy('*.hpp', dst='include/tl', src='include/tl')
|
@@ -1,14 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(PackageTest CXX)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
add_executable(example example.cpp)
|
||||
target_link_libraries(example ${CONAN_LIBS})
|
||||
|
||||
# CTest is a testing tool that can be used to test your project.
|
||||
# enable_testing()
|
||||
# add_test(NAME example
|
||||
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# COMMAND example)
|
@@ -1,25 +0,0 @@
|
||||
import os
|
||||
|
||||
from conans import ConanFile, CMake, tools
|
||||
|
||||
|
||||
class ExpectedTestConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
|
||||
# in "test_package"
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def imports(self):
|
||||
self.copy("*.dll", dst="bin", src="bin")
|
||||
self.copy("*.dylib*", dst="bin", src="lib")
|
||||
self.copy('*.so*', dst='bin', src='lib')
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self.settings):
|
||||
os.chdir("bin")
|
||||
self.run(".%sexample" % os.sep)
|
@@ -1,16 +0,0 @@
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
tl::expected<int, const char*> maybe_do_something(int i) {
|
||||
if (i < 5) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return tl::make_unexpected("Uh oh");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void)argv;
|
||||
|
||||
return maybe_do_something(0).value_or(-1);
|
||||
}
|
Reference in New Issue
Block a user