说我要来存储三种类型的tuple:int,float和std::vector<double>
如果我抛开后续界面的问题,就这样做
tuple<int, float, vector<int>> t;
Run Code Online (Sandbox Code Playgroud)
与此有任何不同
tuple<vector<int>, int, float> t;
Run Code Online (Sandbox Code Playgroud)
由于tuple作为一类可变参数的实现,我期望生成的类有不同的布局,但它有什么关系吗?在将类型放入a tuple(例如,放置最大的第一个等)时,是否还要考虑任何优化注意事项?
C++ 11和C11标准定义了
std :: isfinite
函数.的Visual Studio 2012似乎并没有提供它的一部分
cmath或math.h,但amp_math.h它
似乎提供了这一功能.
是isfinite可以互换std::isfinite?文档没有讨论调用时的行为NAN
,我没有VS编译器来测试它.
我正在尝试创建一个捕获模板,使用<title>链接名称将URL转换为组织模式链接.
我的转换函数如下所示:
(defun get-page-title (url)
"Get title of web page, whose url can be found in the current line"
;; Get title of web page, with the help of functions in url.el
(with-current-buffer (url-retrieve-synchronously url)
;; find title by grep the html code
(goto-char 0)
(re-search-forward "<title>\\([^<]*\\)</title>" nil t 1)
(setq web_title_str (match-string 1))
;; find charset by grep the html code
(goto-char 0)
;; find the charset, assume utf-8 otherwise
(if (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1)
(setq …Run Code Online (Sandbox Code Playgroud) 我有一个类产生任意数量的工作对象,将其结果计算为std::vector.我将在某些点删除一些工作对象,但我希望将它们的结果保持在某个只有类已知的类别的顺序中spawned.因此,我在A类中为输出提供向量.
我有(IMO)三个选项:我可以指向矢量,引用或迭代器作为成员.迭代器选项有一定的缺点(迭代器可以递增.)我不确定指针或引用是否更清晰.我觉得引用更好,因为它们不能为NULL,并且cruncher需要存在向量.
我最不确定的是参考文献的有效性.它们会被某些操作无效std::list< std::vector<int> >吗?这些操作是否与使迭代器无效相同std::list?还有另一种我现在看不到的方法吗?此外,与容器的耦合感觉不对:我将特定容器强制到Cruncher类.
为清晰起见提供了代码
#include <list>
#include <vector>
#include <boost/ptr_container/ptr_list.hpp>
class Cruncher {
std::vector<int>* numPointer;
std::vector<int>& numRef;
std::list< std::vector<int> >::iterator numIterator;
public:
Cruncher(std::vector<int>*);
Cruncher(std::vector<int>&);
Cruncher(std::list< std::vector<int> >::iterator);
};
class A {
std::list< std::vector<int> > container;
boost::ptr_list< std::vector<int> > container2;
std::vector<Cruncher> cruncherList;
};
Run Code Online (Sandbox Code Playgroud) 在emacs中,如果选择了区域,我想将Ck绑定到kill-region; 其他杀线正常.如何配置?
我想在模板类方法中使用迭代器.这是我的代码:(testclass.h)
template<typename T, typename container>
class TestClassX
{
public:
void gen(typename container::iterator first );
};
Run Code Online (Sandbox Code Playgroud)
和文件testclass.cpp:
template<typename T, typename container>
void TestClassX<T, container>::gen(typename container::iterator first)
{
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时:
TestClassX<unsigned, std::vector<unsigned> > testx;
testx.gen(it);
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
Error:undefined reference to `TestClassX<unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > >::gen(__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >)'
Run Code Online (Sandbox Code Playgroud)
我用的是mingw32 4.4
我想有一个类可以写入不同的容器,如std :: vector,std :: list,QVector或QList都有STL样式的迭代器.
在最近关于boost开发者邮件列表的邮件中,Eric Niebler提到可以在O(1)实例化中获取模板参数包的最后一个元素.
如何才能做到这一点?
我必须存储可以按周,每天或每月组织的预定事件(例如说课时).事件可能发生在每个星期一和星期三,或每月的每个星期四.有没有办法将这些信息存储在符合3NF的RDBMS中?
编辑:这不是作业; 我正和朋友一起为我们自己的教化做点什么,我们想要它在3NF.
具体来说,我正试图在RC教区存储大规模和告白时间的时间表.这些可以在很多方面安排,例如每个星期天的x时间或每个星期二/星期四的不同时间.有时它只是本月的第三个星期五,而其他只在一年一次的某个时间提供.我不仅要存储这些信息,还要查询它,以便我可以快速获得第二天或一周或其他任何时间的可用时间的完整列表.
我认为严格来说3NF并不是一个要求,但是对我们来说它会更容易,而且最好是让它更正确,而不是以后更改我们的架构.
我最近遇到了使用配置对象而不是通常的setter方法进行配置的类.一个小例子:
class A {
int a, b;
public:
A(const AConfiguration& conf) { a = conf.a; b = conf.b; }
};
struct AConfiguration { int a, b; };
Run Code Online (Sandbox Code Playgroud)
好处:
A(const AConfiguration& conf = AConfiguration()).缺点:
我缺少更多的缺点吗?如果没有:为什么不经常使用?
我需要知道,如何在给定目录中选择上次修改/创建的文件.
我目前有一个名为XML的目录,里面有很多XML文件.但我想只选择最后修改过的文件.