我如何使用动态WSDL,它的操作和参数,在程序配置文件中给出?
例如,我们有一个配置文件:
[Section]
WSDL=http://example.com/SomePub/ws/SomeService?wsdl
Username=myuser
Password=mypass
OperationName=MyOperation
ParameterName=MyParameter
Run Code Online (Sandbox Code Playgroud)
即我们必须使用未知的web服务,但仅在运行时给出(通过ini文件).所以,我们不能在Delphi中使用WSDL Import向导.
我们可以在Delphi中编写这样一个程序,它可以从配置加载这些设置,然后将数据传递给web-service上指定参数的指定操作,由给定的WSDL指定?
当我使用GCC时,我可以使用以下方法在我的Ubuntu 15.04上构建程序:
-static-libgcc -static-libstdc++
Run Code Online (Sandbox Code Playgroud)
并且编译后的二进制文件可以在"库存"Ubuntu 14.04上运行而无需任何外部软件包,只有标准更新.
是否有可能使用这种静态链接到具有clang的库来构建?
最常见的答案:
ppa:ubuntu-toolchain-r/test
)不适合我.
我可以用clang在Ubuntu 14.04.3 LTS上运行吗?
GoogleTest 中是否有类似的内容:
ASSERT_EQ_ONE_OF_TWO(TestValue, Value1, Value2)
Run Code Online (Sandbox Code Playgroud)
哪个测试如果TestValue == Value1 || TestValue == Value2
?
这个变体:
ASSERT_TRUE(TestValue == Value1 || TestValue == Value2)
Run Code Online (Sandbox Code Playgroud)
可以,但是TestValue
如果失败,它不会在日志中显示哪个值。
enum class E {
One,
Two
};
void foo(E value = decltype(value)::One) {
}
Run Code Online (Sandbox Code Playgroud)
它可以用Clang(3.9)编译,但不能用GCC 6.1编译:value was not declared in this scope
.
什么编译器是对的?
特定
const void * data = ...;
size_t size = ...;
std::string message(???)
Run Code Online (Sandbox Code Playgroud)
如何std::string
从原始指针构造数据和数据大小?data
可能包含NUL字符.
如何初始化静态地图,其中值是std::unique_ptr
什么?
static void f()
{
static std::map<int, std::unique_ptr<MyClass>> = {
{ 0, std::make_unique<MyClass>() }
};
}
Run Code Online (Sandbox Code Playgroud)
当然这不起作用(std::unique_ptr
删除copy-ctor ).
可能吗?
void foo(const std::string& s = "abc") {
// ...
}
// ...
int main() {
// ...
foo();
// ...
}
Run Code Online (Sandbox Code Playgroud)
将s
在foo
被晃来晃去?我认为因为std::string
将从默认值构造"abc"
,然后这将是一个const引用做死临时.
我对吗?
假设我有自定义字符串类:
class my_string : public std::string
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个模板化函数,my_string
默认情况下接受这两个函数:
template <typename TString = my_string>
TString do_something(const TString& input)
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
但当我打电话给:
auto result = do_something("abcdef");
Run Code Online (Sandbox Code Playgroud)
它(当然)打电话do_something<char[7]>()
.如何在do_something<my_string>
没有明确指定类型的情况下强制它调用(即写入do_something("abcdef")
,不是do_something<my_string>("abcdef")
)?
std::clamp
如果其中一个min
或max
参数是rvalues ,最好不要将返回值绑定到const ref .
典型的实现std::clamp
(非常简化):
template <class T>
constexpr const T& clamp(const T& value, const T& min, const T& max)
{
return value < min ? min : max < value ? max : value;
}
Run Code Online (Sandbox Code Playgroud)
正如已经在std :: clamp的cppreference中所述,当有人写道时会出现危险的情况:
int n = -1;
const int& r = std::clamp(n, 0, 255);
// r is dangling
Run Code Online (Sandbox Code Playgroud)
有没有办法编译时检测这些情况?
template <class A>
struct Foo {
template <class Bar>
constexpr auto a_method();
};
template <class A>
template <class Bar>
constexpr auto Foo<A>::a_method() {
return 42;
}
template <>
template <class Bar>
constexpr auto Foo<void>::a_method() {
return 42;
}
Run Code Online (Sandbox Code Playgroud)
GCC可以编译这个。
但铿锵不能。错误输出:
<source>:15:27: error: conflicting types for 'a_method'
constexpr auto Foo<void>::a_method() {
^
<source>:4:18: note: previous declaration is here
constexpr auto a_method();
^
1 error generated.
Compiler returned: 1
Run Code Online (Sandbox Code Playgroud) c++ ×8
clang ×2
c++11 ×1
c++17 ×1
clamp ×1
delphi ×1
gcc ×1
googletest ×1
libstdc++ ×1
lifetime ×1
parameters ×1
soap ×1
templates ×1
ubuntu ×1
unique-ptr ×1
web-services ×1
wsdl ×1