我在GSL的某些部分写了一个小的C++包装器,遇到了下面的谜题(对我来说).代码(简称其基本内容)如下:
#include <stdlib.h>
struct gsl_vector_view {};
class Vector : protected gsl_vector_view {
public:
Vector ( const Vector& original );
Vector ( const gsl_vector_view view );
};
class AutoVector : public Vector {
public:
explicit AutoVector ( const size_t dims );
};
void useVector ( const Vector b ) {}
void test () {
const AutoVector ov( 2 );
useVector( ov );
}
Run Code Online (Sandbox Code Playgroud)
不会使用gcc 4.4.5 g ++ -c v.cpp编译但是yield
In function ‘void test()’:
19: error: call of overloaded ‘Vector(const AutoVector&)’ is …Run Code Online (Sandbox Code Playgroud) 为了演示,我使用3行CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
find_package( BLAS REQUIRED )
message( STATUS BLAS found: ${BLAS_LIBRARIES} )
Run Code Online (Sandbox Code Playgroud)
我有cblas,ATLAS和OpenBLAS,包括安装在Debian Linux系统上的开发人员软件包,以及CMake 2.8.9.我打电话的时候
cmake . -DBLA_VENDOR=ATLAS -DCMAKE_PREFIX_PATH=/usr/lib/atlas-base
Run Code Online (Sandbox Code Playgroud)
很好地看到了ATLAS库:
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: …Run Code Online (Sandbox Code Playgroud) 我想从一个可能很长的输入代码文本中提取一个简单的回溯解析器的标记。我的设置是使用一个整数光标,它保存文本中的下一个阅读位置,最初为 0。然后我想使用substr提取简单的短标记和 perlre 来提取更复杂的标记。因此,后续正则表达式搜索之间的光标位置可能会向前跳跃(在成功的令牌子字符串匹配之后)或向后跳跃(回溯时)。
我的问题是:如何有效地限制 perlregex 搜索的起始位置,以便它仅从该位置搜索匹配的标记。
例如,我想在示例文本中获取十进制数字标记
my $text = 'long text with 2 numbers 3928 in it';
Run Code Online (Sandbox Code Playgroud)
并且当前光标位置是 25。我目前对这个问题的智慧要么是生成一个(可能效率低下的)子字符串
my $tail = substr $text, 25;
printf "%s\n",
$tail =~ /^\d+/
? "match: $&"
: "miss";
Run Code Online (Sandbox Code Playgroud)
或\G通过(可能效率低下的)额外模式匹配来操作修饰符(注意这里25必须是真实标记器中的变量)
$text =~ /.{25}/gcm;
printf "%s\n",
$text =~ /\G\d+/
? "match: $&"
: "miss";
Run Code Online (Sandbox Code Playgroud)
后一种选择具有额外的外观弱点,即它可能不是线程安全的。这在我现在正在做的事情中没有问题,但我也在我的问题中为那些可能使用多线程的人强调了这个问题。