由买买提看人间百态

topics

全部话题 - 话题: templating
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
j*******e
发帖数: 674
1
来自主题: Programming版 - C++ class template specialization question
Thanks for the replies.
I also posted at stackoverflow.com. Their answer is:
The template is not instantiated, so the compiler has the option to report
an error or not. A guy was saying this is actually a very useful feature.
r*******y
发帖数: 1081
2
来自主题: Programming版 - template
template void f(vector::iterator){}
this can not compile because of vector::iterator in the parameter
list. Why this parameter is not allowed here? Thanks.
t****t
发帖数: 6806
3
来自主题: Programming版 - template
template void f(typename vector::iterator) {}
C***y
发帖数: 2546
4
来自主题: Programming版 - C++ function template问题
我有两个function,一个传入pointer,另外一个传入refernce
例如:
void func(int& a);
void func(double* a);
有办法为这两个function写一个function template吗?
Thanks!
C***y
发帖数: 2546
5
来自主题: Programming版 - C++ function template问题
Inside the functions, code is exactly the same.
I can use overloading, but it will duplicate the code. That's why I was
wondering if I can use template instead.
Thanks!
X****r
发帖数: 3557
6
来自主题: Programming版 - C++ function template问题
I'm curious how "int&" and "double*" are used exactly the same?
Anyhow, if this is indeed the case, you can write
template void func(T a) {
//...
}
However, note that this may not work as you expected: to invoke
T=int&, you're likely to need to write "func(x)" for int x,
because by default T=int for int x.
n*****3
发帖数: 1584
7
来自主题: Programming版 - c++ template是不是跟Macro一个道理?
I think template is implemented based on macro.
but when you doing the programming, things are
complete different.
a********m
发帖数: 15480
8
来自主题: Programming版 - c++ template是不是跟Macro一个道理?
类似但是不一样。template是根据类型,用到的时候产生对应代码。macro基本是字符
串替换。
s********e
发帖数: 158
9
测试了一下用g++就好了,用了intel的libirc.a解决了_intel_fast_memcpy的问题,
然后用g++编译的程序用gdb就好了,貌似是intel的问题,大家都用intel的编译器和
idb吗,如果对template支持这么差,怎么用?还有idb不能tab补全,
h**********c
发帖数: 4120
10
来自主题: Programming版 - C++ template preprocessor
Try to figure it out but failed,as the following:
void takefloat (float * ) {}
void takedouble (double *) {}
template
void dosomething (T * pt)
{
#if sizeof(T) == sizeof(float)
takefloat (pt);
#else
takedouble(pt);
#endif
}
Compilation failed.
A**u
发帖数: 2458
11
来自主题: Programming版 - C++ template preprocessor
我觉得,你这个不行的原因在
#if sizeof(T) == sizeof(float)
sizeof(T)要运行时才知道
你改成
#if XXX
#else
#endif
编译时候加上 g++ -DXXX 选择float, g++ 选择double
或者
你改成void take (float * ) {}
void take (double *) {}
template
void dosomething (T * pt)
{
take(pt);
}
这样可行吗
t****t
发帖数: 6806
12
来自主题: Programming版 - C++ template preprocessor
for metaprogramming, there is no "if". condition is always implicit. for
your example (as a simple function), you should write:
void dosomething(float* pt) { takefloat(pt); }
template void dosomething(T* pt) { takedouble(pt); }
although you may really want to write
void dosomething(float* pt) { takefloat(pt); }
void dosomething(double* pt) { takedouble(pt); }
h**********c
发帖数: 4120
13
来自主题: Programming版 - C++ template preprocessor
Try to figure it out but failed,as the following:
void takefloat (float * ) {}
void takedouble (double *) {}
template
void dosomething (T * pt)
{
#if sizeof(T) == sizeof(float)
takefloat (pt);
#else
takedouble(pt);
#endif
}
Compilation failed.
A**u
发帖数: 2458
14
来自主题: Programming版 - C++ template preprocessor
我觉得,你这个不行的原因在
#if sizeof(T) == sizeof(float)
sizeof(T)要运行时才知道
你改成
#if XXX
#else
#endif
编译时候加上 g++ -DXXX 选择float, g++ 选择double
或者
你改成void take (float * ) {}
void take (double *) {}
template
void dosomething (T * pt)
{
take(pt);
}
这样可行吗
t****t
发帖数: 6806
15
来自主题: Programming版 - C++ template preprocessor
for metaprogramming, there is no "if". condition is always implicit. for
your example (as a simple function), you should write:
void dosomething(float* pt) { takefloat(pt); }
template void dosomething(T* pt) { takedouble(pt); }
although you may really want to write
void dosomething(float* pt) { takefloat(pt); }
void dosomething(double* pt) { takedouble(pt); }
g****y
发帖数: 436
16
来自主题: Programming版 - C++ template function type
请问下面MAPPER的type应该如何写?先谢过了!
//hist_helper.h
namespace hist_aux {
template<
typename C,
typename T,
typename MAPPER
>
void getHist(const T& vals,
MAPPER pf,
C& res) {

typename T::const_iterator it;
for (it = vals.begin(); it != vals.end(); ++it) {
res.at(pf(*it))++;
}
}
} /* namespace hist_aux */
namespace hist{
class Hist {
public:
// ctr & dtr
// ...

size_t count_mapper(size_t v);
size_t index_mapper(size_t v);
size_t pixe... 阅读全帖
X****r
发帖数: 3557
17
来自主题: Programming版 - C++ template function type
The point is exactly not to explicitly write the type of any
template parameter and let the compiler deduces them.
Just call histo(...)
f*********y
发帖数: 376
18
来自主题: Programming版 - C++ templates
最近正在读c++ templates: the complete guide 这本书。
我主要觉的书读了,还是要通过练习加深印象呀,否则都忘了。
但是,不知到有啥比较好的project可以练习,而且就算有,似乎也只能
是应用其中一小部分知识。
不知大家有啥方法学习
A**u
发帖数: 2458
19
来自主题: Programming版 - C++ templates
恩。
不用template一样可以写出好软件
H****r
发帖数: 2801
20
来自主题: Programming版 - C++ templates
库的确算C/C++一个软弱的地方哈?不过C/C++提供了自己制作库的能力啊。好的库也听
强的
template 算个优点吧?
d**********x
发帖数: 4083
21
来自主题: Programming版 - C++ templates
template是C++的一个亮点啊
java的那个Generic我吐槽无力了都
但是C++几乎就没有什么通用的,标准的强大的库,每次看到java那些库我都想买把ak
把标准委员会都突突了。。
Qt还行,不过一来那帮人最近搞qml走火入魔,二来Nokia也要把Qt砍了。。。
哦,boost也算个通用的,除此之外。。。
h**********c
发帖数: 4120
22
来自主题: Programming版 - C++ templates
If you write templated classes, you have to write super big .h file. At
least Visual c++.
That is a bloody lesson.
t****t
发帖数: 6806
23
来自主题: Programming版 - One c++ non-type template question
if it's unknown at compile time, no, it can not be done. however, you can
use address of int instead (since global variable address is known at
compile time):
template
void set()
{
cout< }
int t;
int main()
{
/* get value for t */
set();
}
something like that, you may need to do some adjustment.
y***a
发帖数: 840
24
来自主题: Programming版 - template specialization
src code is there:
http://stuff.mit.edu/afs/athena.mit.edu/software/gccgo/current/src/elfcpp/elfcpp_swap.h
问一下在Convert_endian里老使用typedef有什么好处:
比如在164行:
template<>
struct Convert_endian<8, false>
{
typedef Valtype_base<8>::Valtype Valtype; <--- line 164
static inline Valtype
convert_host(Valtype v)
{ return v; }
};
既然已经在做specialization, 直接用uint8_t不就好了吗?z这个Valtype_base<>模板
有什么好处?我没想明白
T********i
发帖数: 2416
25
我有一个1000多行的template code,10多年了,要VC和GCC都能编译。
每个版本的新编译器出来都要改一下。否则就不能编译。
N******K
发帖数: 10202
26
核心库是c++ template写的 打算隐藏起来 只提供一些接口
怎么搞?
ET
发帖数: 10701
27
来自主题: Programming版 - iOS UI template with OC or Swift source code
what do you mean "UI template" ? custom UI?
standard UIs dont' work for you?
L****8
发帖数: 3938
28
来自主题: Programming版 - CNN和template matching到底有啥区别
按照这个文章
https://www.cs.nyu.edu/~fergus/papers/zeilerECCV2014.pdf
直接设计一堆template 然后组装起来 不就行了
h*k
发帖数: 127
29
cool, thx. used to be right click and apply template in DW3.
w****j
发帖数: 237
30
It seems in IEEE latex template, when I use \include to break an article
into several parts, every parts will start from a new page. So how can I do
in latex to avoid this situation, and joint all parts without any break?
Thanks.
c***r
发帖数: 280
31
我是新手。Windows下使用,试图从new from template新建一个文档,但每次总弹出框
口,说
The layout file requested by this document, latex8.layout is not usable.
This is probably because a LaTex class or style file required by it is not
available. See the Customization documentation for more information.
LyX will not be able to produce output.
请问是怎么回事,谢谢大家解答。
l********r
发帖数: 175
32
来自主题: TeX版 - 哪儿找 template?
do you know how to use openoffice to do that? I also need template for
article.
l********r
发帖数: 175
33
I need to submit papers to different journals . I like to use latex but
always need to worry about if I could download the latex template from the
website of that journal. anyone else having similar experience? I feel so
bad for latex now.
e***e
发帖数: 168
34
when i used ACM SIG proceeding latex template, the references's first author
's last name is always in abbreviation. For example,
John Smith, David Wang, "paper name". will displayed as
J.S. and D Wang, "paper name".
Can anyone tell me how to make it like:
J. Smith and D. Wang, "paper name"?
Thanks!
r****j
发帖数: 278
35
来自主题: TeX版 - 用latex ieee trans 的template
【 以下文字转载自 EE 讨论区 】
发信人: rmjlxj (rm), 信区: EE
标 题: 用latex ieee trans 的template
发信站: BBS 未名空间站 (Mon May 11 22:17:24 2009), 转信
怎么加definition?
\newdef好像没用。。
b*****l
发帖数: 9499
36
【 以下文字转载自 Biology 讨论区 】
发信人: bigsail (河马·河东), 信区: Biology
标 题: 哪位有 Molecular Systems Biology 的 latex template
发信站: BBS 未名空间站 (Fri Nov 20 04:43:11 2009, 美东)
拜谢 :)
p*****g
发帖数: 604
37
来自主题: TeX版 - help on elsevier template error
I am using miktex and winedt
I downloaded the newest Elsevier template elsarticle.cls from Elsevier's web
page
but kept got the error msg: font u/psy/m/n/10=psyr at 10.0pt not loadable: M
etric (TFM) file not found.
Can anyone tell me how to fix it?
many thanks
p**n
发帖数: 1437
38
用default的book template,在偶数页的右上角会打上章节的名字,但有的时候章节名
字太长了显示不下,要是用\chapter[短]{长}的话在目录里也会变成“短”,现在希望
章节名字在header里是“短”,在目录和正文里是“长”,那应该怎么做?
多谢!
b*******t
发帖数: 33714
39
什么意思?你是要做slides?
系里没有特别要求的话,就自己写一下,注意一下字体行距什么的就好了阿,不一定非
要搞个template,用也只用这一次。
b*******t
发帖数: 33714
40
这个真的是个人喜好,任何普通的template都可以用,margin notes用\usepackage{
marginnote},foot notes直接可以打,highlighting的话这边有做得很好看的:
http://tex.stackexchange.com/questions/197029/highlight-anythin
不然直接用color package就可以

communicated
margins
setup
h***a
发帖数: 145
41
I remember that most journals have endnote template to download. Go to the
website to check out.
r*******y
发帖数: 48
42
来自主题: Biology版 - 请教CRISPR行家-HDR Template Design
you just need synthesized ssODN as a template for transfection; it is not
necessary to subclone it into plasmd and then release it.
c******d
发帖数: 647
43
来自主题: Biology版 - 请教CRISPR行家-HDR Template Design
非行家,不过最近也在做HDR template,
网上关于sgRNA的资源就不说了,但是关于HDR的简直太少
真的是有做的人可能就直接合成ssODN了,可是我想插入比如FP,两边的arm也想1-1.
5kb 长,所以现在也想自己设计plasmid,现在还没做到那步
Zhang的paper说应该linearize donor vector;但我看到别的source说如果用
linearized donor,会增加随机integration的可能,用全plasmid就可以了

cas9
c******d
发帖数: 647
44
来自主题: Biology版 - 请教CRISPR行家-HDR Template Design
我还有个问题想问你呢,
这个HDR template一般用什么vector backbone呀,还是理论上什么都可以?
哪里可以买到不?
b******h
发帖数: 2715
45
Gaussion software. syntext writing is so bothersome. is there any template
for follow?
thanks
R**X
发帖数: 417
46
来自主题: Chemistry版 - 弱弱的问:JACS full paper template
现在是啦,不过full paper只是推荐template,可以不用的
S****8
发帖数: 401
47
来自主题: Computation版 - C++ templating 关于 稀疏矩阵存储
现在一个项目用的一个 C++ template library叫FLENS 类似于eigen,
我需要储存很多个大小相同的矩阵,在后面的计算中备用,
想法很简单,用 std::vector 容器,
std::vector Dmatrices;
std::vector Smatrices;
// some operations, e.g.
Dmatrices.push_back(Dmatrix1);
Smatrices.push_back(Smatrix1);
结果,dense matrix这样搞是可以的,但是sparse matrix 这样链接的时候就有问题,
我在想是不是因为 std::vector 要求每个element是一样的,而sparse matrix尽管
dimension一样,但本质上而是大小不同的?
s***e
发帖数: 830
48
来自主题: Economics版 - How to use AEA's LATEX template
I am writing a paper in LATEX, but have difficulty useing the template in
the following link?
http://www.aeaweb.org/latex_templates.zip
It will be very appreciated if anybody can help me.
s****e
发帖数: 282
49
【 以下文字转载自 TeX 讨论区 】
发信人: secure (sword), 信区: TeX
标 题: Looking for latex template
发信站: BBS 未名空间站 (Fri Sep 15 12:04:10 2006)
for PHD thesis that meet the requirement of Electronic Theses and
Dissertations (ETD). THX
x***y
发帖数: 830
50
如果哪位有的麻烦给发一份到r****[email protected]
他们放template的地方暂时down了
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)