我在为一个嵌套在模板中的类的异常编写catch子句时遇到问题.更具体地说,我对模板和异常有以下定义:
/** Generic stack implementation.
Accepts std::list, std::deque and std::vector
as inner container. */
template <
typename T,
template <
typename Element,
typename = std::allocator<Element>
> class Container = std::deque
>
class stack {
public:
class StackEmptyException { };
...
/** Returns value from the top of the stack.
Throws StackEmptyException when the stack is empty. */
T top() const;
...
}
Run Code Online (Sandbox Code Playgroud)
我有一个以下模板方法,我希望异常捕获:
template <typename Stack>
void testTopThrowsStackEmptyExceptionOnEmptyStack() {
Stack stack;
std::cout << "Testing top throws StackEmptyException on empty stack..."; …Run Code Online (Sandbox Code Playgroud) 我在源代码中定义了以下div:
<div id="container">
<div id="right">Right</div>
<div id="left">Left</div>
</div>?
Run Code Online (Sandbox Code Playgroud)
我无法对它们进行重新排序,因此我必须使用CSS,以便它们显示在页面上,如下所示:
+---------------------+
| container |
| +-------+-------+ |
| | left | right | |
| +-------+-------+ |
+---------------------+
Run Code Online (Sandbox Code Playgroud)
挑战是#left div的内容可以是任意宽度,无论宽度是多少,我都需要#right div坚持#left div的右边界.任何想法如何实现?
任何帮助赞赏!
此外,还有一个小约束:我需要#left和#right对齐#container div边框的左边.