問:以下のソースを全く同じ動作をするコードを書け。(定数時間)
-----
auto CTest1::TestFunction(unsigned int a, unsigned int b)->unsigned int{
unsigned int ret = 0;
for(unsigned int i = a; i <= b; ++i){
ret += i;
}
return ret;
}
-----
俺には書けなかった・・・
TestFunction(0xfffffffe, 0xfffffffe);
TestFunction(n, 0xffffffff);
あたりを再現できるかが肝心だな。
多分無理だと思うのだが。
class ITest{
public:
virtual auto TestFunction(unsigned int a, unsigned int b)->unsigned int = 0;
};
class CTest1 : public ITest{
public:
virtual auto TestFunction(unsigned int a, unsigned int b)->unsigned int;
};
class CTest2 : public ITest{
public:
virtual auto TestFunction(unsigned int a, unsigned int b)->unsigned int;
};
auto CTest1::TestFunction(unsigned int a, unsigned int b)->unsigned int{
unsigned int ret = 0;
for(unsigned int i = a; i <= b; ++i){
ret += i;
}
return ret;
}
auto CTest2::TestFunction(unsigned int a, unsigned int b)->unsigned int{
if(a <= b){
//普通
unsigned int n = b - a + 1;
unsigned int s = a + b;
if(n & 1){
//項数が奇数
return (s >> 1) * n;
}else{
//項数が偶数
return (n >> 1) * s;
}
}else{
//まず来ない
return 0;
}
}
[ Note: if a program could assign a pointer of type T** to a pointer of type const T** (that is, if line #1
below were allowed), a program could inadvertently modify a const object (as it is done on line #2). For
example,
int main() {
const char c = ’c’;
char* pc;
const char** pcc = &pc; // #1: not allowed
*pcc = &c;
*pc = ’C’; // #2: modifies a const object
}
―end note ]
[ Example:
struct B {
int f();
};
struct L : B { };
struct R : B { };
struct D : L, R { };
int (B::*pb)() = &B::f;
int (L::*pl)() = pb;
int (R::*pr)() = pb;
int (D::*pdl)() = pl;
int (D::*pdr)() = pr;
bool x = (pdl == pdr); // false
―end example ]
本の虫: 今まで知らなかったswitch文の仕様 http://cpplover.blogspot.com/2010/07/switch.html
-----
これは酷い。
-----
void f( int const value )
{
int i = 0 ;
switch( value )
for ( ; i != 10 ; ++i )
{
case 1 : case 2 :
std::cout << "value is 1 or 2" << std::endl ;
continue ;
void f( int const value ){
std::cout << value << std::endl;
int i = 0;
switch(value){
for(; i < 3; ++i){
case 0: std::cout << "test" << std::endl;
case 1: std::cout << "google" << std::endl;
}
break;
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
libs\math\build\..\src\tr1\cyl_bessel_jf.cpp:17:1: warning: visibility attribute
not supported in this configuration; ignored
["DOM functions can be deleted", function () { delete Node.prototype.appendChild; var retVal = !document.appendChild; /* Restore for next iteration */Node.prototype.appendChild = backupAppendChildFunc; return retVal; } ],
あ。
これは駄目だった。
-----
["Cached DOM functions require a 'this' object", function () { var g = document.getElementById; try { var res = g("demobody"); return false; /* this-less invoke should be illegal */ } catch (ex) { } return true; } ],
// New ECMAScript 5 capabilities
["ES5 direct-prototype-access", function () { return Object.getPrototypeOf(document.createElement('div')) == HTMLDivElement.prototype; } ],
["DOM objects can be 'locked' with ES5 preventExtensions", function () { var d = document.createElement('div'); Object.preventExtensions(d); d.extensionVal = "test"; return (d.extensionVal != "test"); } ],
["DOM properties (ES5 accessors) created on appropriate prototypes", function () { return Node.prototype.hasOwnProperty("nodeName"); } ],
["'Get' function of accessor properties can be executed", function () { return document.nodeName == "#document"; } ],
["'Set' function of accessor property can be executed", function () { document.body.lastChild.data = ""; return document.body.lastChild.data == ""; } ],
["DOM accessors can be deleted", function () { delete Element.prototype.tagName; var retVal = document.body.tagName === undefined; /* Restore for next iteration */Object.defineProperty(Element.prototype, "tagName", backupTagNamePropDesc); return retVal; } ],
John Resig - ECMAScript 5 Strict Mode, JSON, and More http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
---
>Additionally, attempts to introduce new variables through an eval will be blocked.
-----
amachangの高速化の手法が使えなくなるね。
-----
var _d = document;
eval("var document = _d;");
-----
のパターンの奴。まあ、strict modeを使わなければいいだけの話だが。
>Access to arguments.caller and arguments.callee now throw an exception. Thus any anonymous functions that you want to reference will need to be named, like so:
な、なんだって!
>>2783
>A user agent must ignore a declaration with an invalid property name or an invalid value. Every CSS 2.1 property has its own syntactic and semantic restrictions on the values it accepts.
と明記されている。
class X { };
class C {
class X { };
static const int number = 50;
static X arr[number];
};
X C::arr[number]; // ill-formed:
// equivalent to: ::X C::arr[C::number];
// not to: C::X C::arr[C::number];
C:\Users\Owner\AppData\Local\Temp\ccSkrfSI.o:main.cpp:(.text+0x34): undefined re
ference to `__gxx_personality_sj0'
C:\Users\Owner\AppData\Local\Temp\ccSkrfSI.o:main.cpp:(.text+0x51): undefined re
ference to `_Unwind_SjLj_Register'
C:\Users\Owner\AppData\Local\Temp\ccSkrfSI.o:main.cpp:(.text+0x12c): undefined r
eference to `_Unwind_SjLj_Unregister'
C:\Users\Owner\AppData\Local\Temp\ccSkrfSI.o:main.cpp:(.text+0x167): undefined r
eference to `_Unwind_SjLj_Resume'
collect2: ld returned 1 exit status
SELECT classdata.name1, classdata.name2, MAX(class.year * 10 + (class.term - 1) * 5) FROM classdata, class WHERE classdata.id = class.classdata_id AND class.year = 2011 AND class.term = 1 GROUP BY class.classdata_id
SQL怖い><
SELECT sikepuri.*, teacher.name AS teacher_name, classdata.name1 AS classdata_name1, classdata.name2 AS classdata_name2, COUNT(DISTINCT teacher.id) AS teacher_count, COUNT(DISTINCT classdata.id) AS classdata_count FROM sikepuri_link LEFT JOIN teacher ON sikepuri_link.teacher_id = teacher.id, sikepuri, classdata WHERE sikepuri_link.sikepuri_id = sikepuri.id AND sikepuri_link.classdata_id = classdata.id AND classdata.id = :classdata_id
SELECT sikepuri_downlog.sikepuri_id AS sikepuri_id, COUNT(*) AS down_count, sikepuri.title AS sikepuri_title, sikepuri.creater AS sikepuri_creater FROM sikepuri_downlog, sikepuri WHERE 1310266968 <= sikepuri_downlog.time AND sikepuri_downlog.time <= 1310276968 AND sikepuri_downlog.sikepuri_id = sikepuri.id GROUP BY sikepuri_downlog.sikepuri_id ORDER BY down_count DESC
SELECT sikepuri_downlog.sikepuri_id AS sikepuri_id, COUNT(*) AS down_count, sikepuri.title AS sikepuri_title, sikepuri.creater AS sikepuri_creater, classdata.name1, COUNT(DISTINCT classdata.id) AS classdata_count FROM sikepuri_downlog, sikepuri LEFT JOIN sikepuri_link ON sikepuri.id = sikepuri_link.sikepuri_id LEFT JOIN classdata ON sikepuri_link.classdata_id = classdata.id WHERE 1310266968 <= sikepuri_downlog.time AND sikepuri_downlog.time <= 1310276968 AND sikepuri_downlog.sikepuri_id = sikepuri.id GROUP BY sikepuri_downlog.sikepuri_id ORDER BY down_count DESC, sikepuri_id ASC
6.3 Timers — HTML5 http://www.w3.org/TR/html5/timers.html#dom-windowtimers-settimeout
---
If the currently running task is a task that was created by the setTimeout() method, and timeout is less than 4, then increase timeout to 4.
-----
4ms以下の場合は4msになるらしい。これはいい情報だ。
SMTPの仕様に従っていない、SMTPもどきサーバー。 by Ruby
-----
require 'socket'
require 'kconv'
def log(*str)
str.each{|s|
print s.to_s.tosjis
}
end
class String
def startwith(str)
self.slice(0, str.length) === str
end
end
gs = TCPServer.open(25)
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(':'))
while true
Thread.start(gs.accept) do |s|
log s, " is accepted.\n"
s.write "220 OK\r\n"
line = s.gets
if line.startwith('EHLO')
s.write "502 ERR\r\n"
line = s.gets
end
if !line.startwith('HELO')
s.write "500 ERR\r\n"
s.close
return
end
s.write "250 OK\r\n"
while !(line = s.gets).startwith('DATA')
s.write "250 OK\r\n"
log line
end
s.write "354 ENTER\r\n"
log line
while !((line = s.gets) === ".\r\n")
log line
end
s.write "250 OK\r\n"
if !(line = s.gets).startwith('QUIT')
s.write "500 ERR\r\n"
s.close
return
end
s.write "221 CLOSE\r\n"
def log(*str)
str.each{|s|
print s.to_s.tosjis
}
end
class String
def startwith(str)
self.slice(0, str.length) === str
end
end
gs = TCPServer.open(25)
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(':'))
while true
Thread.start(gs.accept) do |s|
log s, " is accepted.\n"
s.write "220 OK\r\n"
line = s.gets
if line.startwith('EHLO')
s.write "502 ERR\r\n"
line = s.gets
end
if !line.startwith('HELO')
s.write "500 ERR\r\n"
s.close
return
end
s.write "250 OK\r\n"
while !(line = s.gets).startwith('DATA')
s.write "250 OK\r\n"
log line
end
s.write "354 ENTER\r\n"
log line
body = []
while !((line = s.gets) === ".\r\n")
log line
body.push line
end
s.write "250 OK\r\n"
if !(line = s.gets).startwith('QUIT')
s.write "500 ERR\r\n"
s.close
return
end
s.write "221 CLOSE\r\n"
log s, " is done.\n"
s.close
if body.length != 0
key = nil
bodystr = ''
body.each do |line|
if line.startwith 'To:'
key = line[/\d{10,}/]
break
end
end
lambda do
state = 0
body.each do |line|
if state == 0 && line == "\r\n"
state = 1
elsif state == 1
bodystr << line.chomp << "\n"
end
end
end.call
Net::HTTP.post_form(
URI.parse('http://jbbs.livedoor.jp/bbs/write.cgi/computer/38153/1307542890/'),
{
'DIR' => 'computer',
'BBS' => '38153',
'KEY' => key,
'TIME' => Time.now.to_i.to_s,
'NAME' => '',
'MAIL' => '',
'MESSAGE' => bodystr.toeuc
}
) if key != nil && !bodystr.empty?
end
end
end
SELECT down_table.sikepuri_id AS sikepuri_id, down_table.down_count AS down_count, sikepuri_table.sikepuri_title AS sikepuri_title, sikepuri_table.sikepuri_creater AS sikepuri_creater, sikepuri_table.sikepuri_kind AS sikepuri_kind, sikepuri_table.classdata_id AS classdata_id, sikepuri_table.classdata_name1 AS classdata_name1, sikepuri_table.classdata_count AS classdata_count FROM (SELECT sikepuri_id, COUNT(*) AS down_count FROM sikepuri_downlog GROUP BY sikepuri_id) AS down_table, (SELECT sikepuri.id AS sikepuri_id, sikepuri.title AS sikepuri_title, sikepuri.kind AS sikepuri_kind, sikepuri.creater AS sikepuri_creater, classdata.id AS classdata_id, classdata.name1 AS classdata_name1, COUNT(DISTINCT classdata.id) AS classdata_count FROM sikepuri LEFT JOIN sikepuri_link ON sikepuri.id = sikepuri_link.sikepuri_id LEFT JOIN classdata ON sikepuri_link.classdata_id = classdata.id GROUP BY sikepuri.id) AS sikepuri_table WHERE down_table.sikepuri_id = sikepuri_table.sikepuri_id
Apply for WoSign Digital Certificates online: SSL Certificates| Code Signing Certificates| EV SSL Certificates | OV SSL Certificates | DV SSL Certificates | 2048bits Web Server Certificate, Support all types of browsers and servers, and support with Chinese in certificate subject, Support IDN domain names ! https://buy.wosign.com/free/
-----
中国製の無料SSL証明書発行サイトらしい
Think-Silicon/GLOVE: GLOVE (GL Over Vulkan) is a software library that acts as an intermediate layer between an OpenGL application and Vulkan https://github.com/Think-Silicon/GLOVE