当你将键盘框架拖离屏幕时,我正在画一个关于如何获得键盘框架的空白.我知道如何使用UIKeyboardWillShowNotification,UIKeyboardWillChangeFrameNotification,UIKeyboardDidChangeFrameNotification开始或结束动画,但是当你将它拖离屏幕时我正在寻找持续更新.例如,我想知道键盘的框架在此拖动点的位置

我正在尝试使用键盘框架来调整桌面视图,该视图应该在向下拖动时正对着键盘.
任何帮助,将不胜感激.
谢谢,
韦斯
假设我要制作一个新的演绎指南,以便进行以下操作?
std::string str;
std::basic_string_view sv = str;
Run Code Online (Sandbox Code Playgroud)
Would that be an Ok customization ?
c++ c++-faq language-lawyer deduction-guide class-template-argument-deduction
这似乎可以正确编译:
namespace A {
template<typename T>
struct S {};
namespace B {
using S = S<int>;
}
}
int main() {
using namespace A::B;
S s;
}
Run Code Online (Sandbox Code Playgroud)
即使在这一行using S = S<int>,第一个S是指A::B::S,而第二个S是指模板A::S。
这是标准的 C++ 吗?
这是相关代码的链接:
#include <iostream>
#include <string>
#include <vector>
#include <type_traits>
int main()
{
std::vector<int> v{1, 2, 3, 4, 5};
auto iter = begin(std::move(v));
if(std::is_const<typename std::remove_reference<decltype(*iter)>::type>::value)
std::cout<<"is const\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
http://coliru.stacked-crooked.com/a/253c6373befe8e50
我遇到了这种行为,因为declval<Container>()在decltype表达式中std::begin.gcc和clang都返回迭代器,在解除引用时会产生const引用.它可能是有意义的,因为r值引用通常绑定到您不想变异的过期对象.但是,我找不到任何关于此的文件来确定它是否符合标准.我找不到任何相关的重载begin()或重新限定的重载Container::begin().
更新:答案澄清了正在发生的事情,但相互作用可能很微妙,如下所示:
#include <iostream>
#include <string>
#include <vector>
#include <type_traits>
int main()
{
if(std::is_const<typename std::remove_reference<decltype(*begin(std::declval<std::vector<std::string>>()))>::type>::value)
std::cout<<"(a) is const\n";
if(!std::is_const<typename std::remove_reference<decltype(*std::declval<std::vector<std::string>>().begin())>::type>::value)
std::cout<<"(b) is not const\n";
if(!std::is_const<typename std::remove_reference<decltype(*begin(std::declval<std::vector<std::string>&>()))>::type>::value)
std::cout<<"(c) is not const\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
http://coliru.stacked-crooked.com/a/15c17b288f8d69bd
天真地,你不会期望(a)和(b)的不同结果当:: begin刚刚用调用vector :: begin来定义时.但是缺少std :: begin重载,它采用非const …
当使用代码(在我的情况下,大多数情况下是c ++),特别是使用git和gitlab时,我经常发现自己在处理特定的合并请求和功能添加工作了几周。最后,我提出了一个很长的合并请求,维护者很难理解,因为我已经做了很多更改。
这些更改中的一些是有意且对手边的功能很重要,而其他更改则微不足道,例如修复了代码的特定部分的缩进,我经常在调试时提高其可读性。但是,为了使MR尽可能小,我希望在从MR移除WIP标签之前“撤消”所有不影响代码本身(但仅影响布局)的琐碎更改。因此,我有时会发现自己正在阅读我的MR,并手动撤消所有这些修饰,以使MR对审阅者更具可读性。
这是很多愚蠢的工作,可以花在其他地方。
我是否可以使用脚本或机制(特别是在C ++代码上)遍历代码并撤消有关某个提交的所有琐碎更改(例如,空格更改)?这将大大简化我的生活。我可以看到自己为此编写了脚本,但是我希望可以使用一些git魔术,或者希望已经为我解决了这个问题的其他人。有什么建议么?
引用C ++ 11:(18.2 / 9)
nullptr_t定义如下:Run Code Online (Sandbox Code Playgroud)namespace std { typedef decltype(nullptr) nullptr_t; }
nullptr_t作为同义词的类型具有在3.9.1和4.10中描述的特征。[注意:虽然nullptr不能使用的地址,但是nullptr_t可以使用作为左值的另一个对象的地址。—尾注]
我们是否需要类型的对象nullptr_t(除外nullptr)?
在某些站点上,我发现这void是标量类型:
https://ee.hawaii.edu/~tep/EE160/Book/chap5/section2.1.3.html
http://herbert.the-little-red-hair-girl.org/en/prgmsc1/docs/part2a.pdf
其他站点不包含有关此信息:
是void标量类型吗?
看这个简单的例子:
template <typename T>
const T const_create() {
return T();
}
struct Foo { };
int main() {
auto &x = const_create<Foo>(); // compiles
// auto &x = const_create<int>(); // doesn't compile
}
Run Code Online (Sandbox Code Playgroud)
为什么版本可以Foo编译,而int不能编译?换句话说,为什么const要从返回类型中删除const_create<int>?它的工作方式就像它返回一样int,不是const int。这不是语言上的矛盾吗?
标准在哪里规定这种行为?
考虑这个库头:
#include<vector>
#include<algorithm>
#include<iostream>
namespace Lib {
namespace detail {
using namespace std;
template<class T>
void sort_impl(istream &in,ostream &out) {
vector<T> v;
{
int n;
in >> n;
v.resize(n);
}
for(auto &i : v) cin >> i;
sort(v.begin(),v.end());
for(auto i : v) out << i << endl;
}
}
inline void sort_std() {
detail::sort_impl<int>(std::cin,std::cout);
}
}
Run Code Online (Sandbox Code Playgroud)
detail命名空间是否成功地将库的客户端(以及库的其余部分实现)与此示例中的using-directive隔离开来?我对于为什么"使用命名空间std"被认为是不良做法的讨论不感兴趣?即使某些论据甚至适用于"包含良好"的使用指令.
请注意,有两个关于相同情况但存在使用声明的问题:
这可以与它们中的任何一个组合,但编辑将是严重的.
在介绍概念和约束之前,有几种方法可以模拟此编译时检查。以“ order()”功能为例:(如何在LessThanComparable没有概念或约束的情况下实施是另一回事)
使用 static_assert
template <typename T, typename U>
void order(T& a, U& b)
{
static_assert(LessThanComparable<U,T>, "oh this is not epic");
if (b < a)
{
using std::swap;
swap(a, b);
}
}
Run Code Online (Sandbox Code Playgroud)
这种方法不适用于函数重载。
使用 typename = enable_if
template <typename T, typename U,
typename = std::enable_if_t<LessThanComparable<U,T>>>>
void order(T& a, U& b)
{
if (b < a)
{
using std::swap;
swap(a, b);
}
}
Run Code Online (Sandbox Code Playgroud)
如果过分“聪明”的家伙用手指定了第三个参数怎么办?
使用enable_if的函数原型:
template <typename T, typename U>
std::enable_if_t<LessThanComparable<U,T>>, void> order(T& a, U& b) …Run Code Online (Sandbox Code Playgroud)